我想記錄參與事務的EJB方法的錯誤或成功。我應該在哪裏放置伐木工具?據我所知,在我的doSomething
完成後,交易將會發生。所以在這種方法中我不能確定提交是否成功。這引發了這個問題。從EJB記錄事務成功
public class MyEjb {
@Inject
AnotherEjb anotherEjb;
@Inject
LoggerEjb logger;
public void doSomeThing() {
MyBean b = getSomething();
anotherEjb.persistSg(b);
/* logger.log is transaction if of attrubute NOT_SUPPORTED to
ensure separation from caller transaction */
logger.log("Did something successfully.");
}
}
public class AnotherEjb {
@Inject
EntitiyManager em;
public void persistSg(MyBean entity) {
em.persist(entity);
}
}
是您bean是否在執行任何數據庫插入/刪除/更新,還是隻調用另一個bean /類來執行此操作? – ChadNC 2012-08-01 11:50:43