HIbernate符合Java习惯的关系数据库持久化之实例状态
An instance of a persistent class can be in one of three different states. These states are defined in relation to a persistence context. The Hibernate Session object is the persistence context. The three different states are as follows:
The instance is not associated with any persistence context. It has no persistent identity or primary key value.
持久化(persistent)Theinstance is currently associated with a persistence context. It has apersistent identity (primary key value) and can have a correspondingrow in the database. For a particular persistence context, Hibernate guarantees that persistent identity is equivalent to Java identity in relation to the in-memory location of the object.
脱管(detached)Theinstance was once associated with a persistence context, but thatcontext was closed, or the instance was serialized to another process.It has a persistent identity and can have a corresponding row in thedatabase. For detached instances, Hibernate does not guarantee therelationship between persistent identity and Java identity.