ejbjava-ee-5

Does not setting @TransactionManagement default to CONTAINER?


I encountered the problem that Mockito refuse to mock any Class with the annotation @TransactionManagement. Now I know that this annotation is not required if you want container managed transaction in jee6. Is this also the case in jee5?


Solution

  • Container managed transactions have been the default in EJB containers since EJB 3.0 (part of Java EE 5). Prior to this you were required to specify the transaction-type as Bean or Container in the ejb-jar.xml deployment descriptor.

    The javadoc for javax.ejb.TransactionManagement states:

    If this annotation is not used, the bean is assumed to have container-managed transaction management.

    Furthermore, §13.3.6 of the EJB-3.0 Specification also states:

    By default, a session bean or message-driven bean has container managed transaction demarcation if the transaction management type is not specified.