Hibernate object equality checking
Posted
by Sujee
on Stack Overflow
See other posts from Stack Overflow
or by Sujee
Published on 2010-06-01T11:58:10Z
Indexed on
2010/06/01
12:43 UTC
Read the original article
Hit count: 241
hibernate
As far as I understand(correct me if I am wrong) Hibernate uses object reference to check the object equality. When Hibernate identifies that there are more than one objects attached to same DB record, it throws following exception.
"a different object with the same identifier value was already associated with the session"
My question is, does Hibernate use equal()
method to check the object equality (The default equal method uses object reference)? If it is true, will overridden equal()
method change the Hibernate behavior?
Note: My question is not about the issues of implementing equal()
or hashCode()
methods in a Hibernate persisted object.
Thank you.
© Stack Overflow or respective owner