Object identity vs Object equality
Object identity (==) is defined by the JVM, Two object
references are identical if they point to the same memory location in the JVM.
Object equality is defined by the classes that implement
equals() method, Two different objects have the same value. This concept
sometimes called as equivalence.
Object stored in the relational database are identical If they
represents the same row or they share the same identifier values. This concept
is known as database identity.
Handling database identity
Hibernate expose database identity in two ways
(1) value of a identifier property of a persistent instance.
(2) value returned by session.getIdentifier(Object entity).
Handling database identity
Hibernate expose database identity in two ways
(1) value of a identifier property of a persistent instance.
(2) value returned by session.getIdentifier(Object entity).