读书人

HIbernate契合Java习惯的关系数据库持

发布时间: 2012-10-25 10:58:57 作者: rapoo

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:

瞬态(transient)

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.

读书人网 >其他数据库

热点推荐