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
|