[J2EE] JPA JTA

看板java作者 (.....)時間10年前 (2015/08/03 22:59), 10年前編輯推噓1(104)
留言5則, 3人參與, 最新討論串1/4 (看更多)
persistence.xml <persistence-unit name="..." transaction-type="JTA"> ... @Stateless public class EjbService implements EjbServiceRemote { @PersistenceContext EntityManager em ; @Resource SessionContext ctx ; @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void test(){ User u = new User(...) ; em.persist(u); em.flush(); ctx.setRollbackOnly(); } } 誰能告訴我...為什麼多了 em.flush() 就不會 rollback.... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.226.35.63 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1438613987.A.25D.html ※ 編輯: luoqr (36.226.35.63), 08/03/2015 23:00:55

08/03 23:05, , 1F
Jboss eap 6.3+hibernate
08/03 23:05, 1F

08/04 09:48, , 2F
datasource 是不是設 auto-commit?
08/04 09:48, 2F

08/04 14:53, , 3F
Synchronize the persistence context to the underlying
08/04 14:53, 3F

08/04 14:53, , 4F
database->api說同步到資料庫
08/04 14:53, 4F

08/04 21:17, , 5F
自問自答.後來發現JBoss有個datasource enable JTA設定要開
08/04 21:17, 5F
文章代碼(AID): #1Llu7Z9T (java)
討論串 (同標題文章)
文章代碼(AID): #1Llu7Z9T (java)