看板 java 關於我們 聯絡資訊
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
luoqr: Jboss eap 6.3+hibernate 08/03 23:05
kojilin: datasource 是不是設 auto-commit? 08/04 09:48
swpoker: Synchronize the persistence context to the underlying 08/04 14:53
swpoker: database->api說同步到資料庫 08/04 14:53
luoqr: 自問自答.後來發現JBoss有個datasource enable JTA設定要開 08/04 21:17