-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: transientobjectexceptions when upgrading to ejb 3.0 / JPA
PostPosted: Tue May 08, 2007 1:05 pm 
Newbie

Joined: Sat Nov 19, 2005 3:09 pm
Posts: 6
Before I post lots code, I just want confirmation that my assumptions are correct about how hibernate and/or jpa deals with detached and reattached objects.

Using hibernate 3.0.2 on jboss 4.0.2 I was successfully loading a form representing a university, with a UniversityType reference object selectable in a list, and saving the University on a form submit. It could be either a brand new university or a modified one. Either way I called saveOrUpdate on it and it would work as expected.

Now I am getting a TransientObjectException on the UniversityType. I am guessing that it is because the UniversityType objects were loaded on a separate session when loading the form, and then a new session was opened when the form was submitted to save the University object.

I believe it worked before because hibernate was using unsaved-value attributes on the UniversityType entity and thus it could figure out whether it was supposed to be saved or not. I don't see a related annotation.

So am i correct that the entity manager cannot save an entity that has a reference ManyToOne entity that was loaded from a different session? If that is true, then how would i solve the problem of loading and submitting this university edit form?

If i'm wrong i'll look through my code and narrow down where i went wrong.

Thanks for reading,
k


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.