EJB: Avoid Transaction rollback

后端 未结 2 2079
天涯浪人
天涯浪人 2021-02-05 08:24

When a (transactional) method of an EJB calls another (transactional) method of another EJB, and an exception is thrown in the second, but catched in the first one, it seems tha

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 08:55

    Yes, it's true, if the exception is a runtime exception. Checked exceptions don't cause a transaction rollback.

    To avoid it, just make sure that the code in methodB doesn't throw any runtime exception. A runtime exception normally indicates a bug, or a state which doesn't allow for continuing the work.

提交回复
热议问题