【发布时间】:2014-05-19 21:42:43
【问题描述】:
我有一个 EJB 无状态会话 Bean,如下所示:
public void persist(Customer customer,Child child){
try{
em.persist(customer);
Father father = new Father();
father.setChild(child); here child is null
em.persist(father);
}catch(Exception e){
}
}
当异常 (NullPointerException) 发生时,事务不会回滚并且客户实体被持久化,但是当我用
捕获异常时 public void persist(Customer customer,Child child){
try{
em.persist(customer);
Father father = new Father();
father.setChild(child); here child is null
em.persist(father);
}catch(EJBException e){
}
}
事务正在回滚,但我不明白为什么,NullPointerException 扩展了 RuntimeException。文档说 RuntimeException 导致回滚。
【问题讨论】:
标签: java transactions ejb