| Author |
ejb3unit and persistence
|
Harshana Dias
Ranch Hand
Joined: Jun 11, 2007
Posts: 325
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Harshana,
Can you show some more code? How does "object" get created?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Harshana Dias
Ranch Hand
Joined: Jun 11, 2007
Posts: 325
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
|
Moving to ORM forum since this is now a question about how JPA/EJB 3 works.
|
 |
 |
|
|
subject: ejb3unit and persistence
|
|
|