[J2EE] JPA JTA

楼主: luoqr (.....)   2015-08-03 22:59:44
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....
楼主: luoqr (.....)   2015-08-03 23:05:00
Jboss eap 6.3+hibernate
作者: kojilin (阿~~小达达)   2015-08-04 09:48:00
datasource 是不是设 auto-commit?
作者: swpoker (swpoker)   2015-08-04 14:53:00
Synchronize the persistence context to the underlyingdatabase->api说同步到数据库
楼主: luoqr (.....)   2015-08-04 21:17:00
自问自答.后来发现JBoss有个datasource enable JTA设定要开

Links booklink

Contact Us: admin [ a t ] ucptt.com