Hi,
I am constantly experience problems when trying to lazily load properties of an object.
My object overwrites equals and hashcode correctly. When I try to reassociate the object with the current session using LockMode.NONE I get a net.sf.hibernate.NonUniqueObjectException.
Correct is, that an Object of this type is already associated with the session, but because I have overwritten equals and hashcode Hibernate should know that this object is the same and not a different object?
Am I correct?
Code:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 4926, of class: wilken.openshop.modules.base.bo.BusinessPartner
at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1605)
at net.sf.hibernate.impl.SessionImpl.reassociate(SessionImpl.java:1611)
at net.sf.hibernate.impl.SessionImpl.lock(SessionImpl.java:1636)
at org.springframework.orm.hibernate.HibernateTemplate$7.doInHibernate(HibernateTemplate.java:233)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.lock(HibernateTemplate.java:231)
I inserted std out debug information into my equals and hashcode methods, but the messages never appear on std out, so I guess these methods never get called by Hibernate.
Any help greatly appreciated.
Best regards,
juergen