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