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....