I am a Solivagant
Lofter    Posts     新文章     文章管理     新日记     日记管理

[Hibernate] official tutorial - userguide

Persistence contexts

org.hibernate.Session API and javax.persistence.EntityManager API represent a context for dealing with persistent data. This concept is called  apersistencec context. Persistent data has a state in relation to both a persistence context and the underlying database.

transient瞬时

The entity has just been instantiated and is not assocaiated with a persistence context.

It has no persistent representation in the database and typically no identifier value has been assigned(unless the assigned generator was used).

managed, or persistent 持久的]

实体有一个关联的标识符,并且和持久化上下文关联.

物理地存在或者不存在于数据库中.

detached 托管的,游离的

有关联的标识符,但是不再和持久化上下滑关联(通常因为持久化上下文被关闭或者实例被上下文清除.

removed

实体有关联的标识符并且和持久化上下文关联,然而它被计划从数据库中移除.

大多数org.hibernate.Session API and javax.persistence.EntityManager API的方法处理实体在这些状态之间的变动.

-------------从JPA中访问Hibernate APIs--------

Session session = entityManager.unwrap( Session.class );
SessionImplementor sessionImplementor = entityManager.unwrap( SessionImplementor.class );

SessionFactory sessionFactory = entityManager.getEntityManagerFactory().unwrap( SessionFactory.class );
----------------

posted @ 2018-06-13 10:43  宛如ZZ  阅读(173)  评论(0编辑  收藏  举报