An instance of a persistent classes may be in one of three different states, which are defined with respect to a persistence context. The Hibernate
Session object is the persistence context:
The instance is not, and has never been associated with any persistence context. It has no persistent identity (primary key value).
The instance is currently associated with a persistence context. It has a persistent identity (primary key value) and, perhaps, a corresponding row in the database. For a particular persistence context, Hibernate guarantees that persistent identity is equivalent to Java identity (in-memory location of the object).
The instance was once associated with a persistence context, but that context was closed, or the instance was serialized to another process. It has a persistent identity and, perhaps, a corrsponding row in the database. For detached instances, Hibernate makes no guarantees about the relationship between persistent identity and Java identity.