How does Hibernate detect dirty state of an entity object?
Posted
by
???'Lenik
on Stack Overflow
See other posts from Stack Overflow
or by ???'Lenik
Published on 2011-03-11T02:54:08Z
Indexed on
2011/03/11
8:10 UTC
Read the original article
Hit count: 256
Is it using some kind of byte codes modification to the original classes?
Or, maybe Hibernate get the dirty state by compare the given object with previously persisted version?
I'm having a problem with hashCode()
and equals()
methods for complicated objects. I feel it would be very slow to compute hash code if the object has collection members, and cyclic references are also a problem.
If Hibernate won't use hashCode()
/equals()
to check the dirty state, I guess I should not use equals()
/hashCode()
for the entity object (not value object), but I'm also afraid if the same operator (==
) is not enough.
So, the questions are:
How does Hibernate know if a property of an object is changed?
Do you suggest to override the
hashCode()
/equals()
methods for complicated objects? What if they contains cyclic references?And, also,
Would
hashCode()
/equals()
with only theid
field be enough?
© Stack Overflow or respective owner