トランザクションに参加しているEJBメソッドのエラーまたは成功をログに記録したいと思います。伐採はどこに置けばいいですか?私の知る限り、トランザクションは私のdoSomething
終了後にコミットされます。したがって、その方法では、コミットが成功するかどうかはわかりません。それはこの質問を提起しました。
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);
}
}