作者luoqr (.....)
看板java
标题[J2EE] JPA JTA
时间Mon Aug 3 22:59:44 2015
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://webptt.com/cn.aspx?n=bbs/java/M.1438613987.A.25D.html
※ 编辑: luoqr (36.226.35.63), 08/03/2015 23:00:55
1F:→ luoqr: Jboss eap 6.3+hibernate 08/03 23:05
2F:推 kojilin: datasource 是不是设 auto-commit? 08/04 09:48
3F:→ swpoker: Synchronize the persistence context to the underlying 08/04 14:53
4F:→ swpoker: database->api说同步到资料库 08/04 14:53
5F:→ luoqr: 自问自答.後来发现JBoss有个datasource enable JTA设定要开 08/04 21:17