1
通读Java Persistence Entity Operations ATM,它具有以下声明它:JPA持久性上下文何时结束?
JPA通过当他们序列化或当一个持久化上下文结束自动分离实体提供了这种模式的支持。
何时持久性上下文结束?它是否在每笔交易的结尾?
通读Java Persistence Entity Operations ATM,它具有以下声明它:JPA持久性上下文何时结束?
JPA通过当他们序列化或当一个持久化上下文结束自动分离实体提供了这种模式的支持。
何时持久性上下文结束?它是否在每笔交易的结尾?
当调用EntityManager.close()
时,持久性上下文结束。 Here's an example。
MagazineId mi = new MagazineId();
mi.isbn = "1B78-YU9L";
mi.title = "JavaWorld";
// updates should always be made within transactions; note that
// there is no code explicitly linking the magazine or company
// with the transaction; JPA automatically tracks all changes
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Magazine mag = em.find(Magazine.class, mi);
mag.setPrice(5.99);
Company pub = mag.getPublisher();
pub.setRevenue(1750000D);
em.getTransaction().commit();
// or we could continue using the EntityManager...
em.close();
怎么样JTA管理:
又如从问题中提供的链接取? – pirho