JEE7: Do EJB and CDI beans support container-managed transactions?

前端 未结 2 1254
小蘑菇
小蘑菇 2020-11-29 03:06

Java EE7 consists of a bunch of \"bean\" definitions:

  • Managed Beans 1.0 (JSR-316 / JSR-250)
  • Dependency Injection for Java 1.0 (JSR-330)
  • CDI 1
2条回答
  •  再見小時候
    2020-11-29 03:36

    The javadoc of Transactional says:

    The javax.transaction.Transactional annotation provides the application the ability to declaratively control transaction boundaries on CDI managed beans, as well as classes defined as managed beans by the Java EE specification, at both the class and method level where method level annotations override those at the class level.

    So, your assumptions are wrong. EJBs, until Java EE 6, were the only kinds of components to support declarative transactions. The Transactional annotation has precisely been introduced in Java EE 7 to make non-EJB, managed CDI beans transactional.

提交回复
热议问题