-->
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: Hibernate replicate in memory object
PostPosted: Thu Sep 24, 2009 10:51 pm 
Newbie

Joined: Sun Feb 18, 2007 1:05 pm
Posts: 16
Hi,
I have a Parent - Child object relation.Child have a reference to the Parent object.
The scenario is like this
I have loaded the Parent object and came out of hibernate session (I have used sessionfactory.getCurrentSession()).
Now the Parent object is in my application memory( HttpSession ).
In another hibernate session (again using sessionFactory.getCurrentSession , i believe this time it would be a different hibernate session) I have loaded all the Child objects for that Parent. Each of the child object refer the parent.
As per my understanding , I would expect all these Child object would be referring the same Parent object that I have loaded before. But unfortunately all these child object referring separate Parent objects (whose values and identifier properties are all same) . I have equals() method properly overridden in the Parent class.
Is this a rite behavior from hibernate.Can anybody suggest what I am doing wrong here ?

And because of this (I believe so) I am getting "a different object with the same identifier value was already associated with the session" exception, when I try to update the Parent.

Please suggest

Thanks in adavance
Shaiju


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.