-->
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.  [ 2 posts ] 
Author Message
 Post subject: Reusing objects across sessions?
PostPosted: Mon Nov 06, 2006 10:59 am 
Newbie

Joined: Mon Nov 06, 2006 9:50 am
Posts: 4
I have the following situation: I have loaded an object of class A (A0), which has several children of class B (B0 and B1), and closed the session in which that happened. In a new session, I now load A1, with children B0 and B2. There are now two different instances of object B0, while I would like there to be just one. Is it possible to do this with Hibernate?

thanks,

Jeroen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 11:14 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Once you detach the domain objects from Hibernate, Hibernate has no way of knowing about them. The only way to accomplish what you are trying to do is by reattaching A0 to the new session (with session.lock), with cascade="lock" (or equivalent) on the B collection. Then, when you load A1, the first level cache should return the cached B0 entity (afaik).


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

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.