Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb3unit and persistence

 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my test class there is a call to persist an object.

Following is the class code snippet which save the object.


INFO: Exception occured org.ejb3unit.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before merging: com.text.domain.ABC

Also the object I am passing in the test class is not transient also...so why this exception occurs?

Thank You.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harshana,
Can you show some more code? How does "object" get created?
 
Harshana Dias
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the late reply Jeanne..well its like this,

Well I create a that object which is type PQR using new() in my EJBUnit class..where that PQR object has a relationship with ABC like following,



So what i realise is when using merge() we have to use a PQR object which exists in database rather create new one and that exception goes.
And with persist() that doest matter even object is created newly or already exists in DB...(mm not sure about that..have to try it..)

So the difference is come from the difference of mereg() and persist() method..where in merge method cant apply to new objects which does not persist in database right? so can some one elaborate this fact more theoretically what is the reason?

Thank You.






 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to ORM forum since this is now a question about how JPA/EJB 3 works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic