EntityManagerFactory emf = Persistence.createEntityManagerFactory("myDb"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); try { tx.begin(); // ... tx.commit(); } catch (Exception e) { if (tx.isActive()) { tx.rollback(); } } finally { em.close(); emf.close(); }


上一篇:
下一篇:
切换中文