aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on container-managed transaction Demarcation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question on container-managed transaction Demarcation" Watch "Question on container-managed transaction Demarcation" New topic
Author

Question on container-managed transaction Demarcation

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Source:EJB 3.1 Specification


4.3.3 The SessionContext Interface

One of the methods of SessionContext interface is :


The setRollbackOnly method allows the instance to mark the current transaction such
that the only outcome of the transaction is a rollback. Only instances of a session bean with
container-managed transaction demarcation can use this method.


What does "container-managed transaction demarcation " means here ?


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

Transactions are either managed by the Container: they are having a so called container-managed transaction demarcation, or
transactions are managed programmatically by the developer: they are having a bean-managed transaction demarcation.

From the EJB-specs:
13.3.1 Bean-Managed Versus Container-Managed Transaction Demarcation
When designing an enterprise bean, the developer must decide whether the enterprise bean will demarcate transactions programmatically in the business methods (bean-managed transaction demarcation), or whether the transaction demarcation is to be performed by the container based on the transaction attributes specified in metadata annotations or in the deployment descriptor


Coming back to the SessionContext method setRollbackOnly() can only be used if your Session bean has:
- the annotation @TransactionManagement(TransactionManagementType.CONTAINER) on the EJB class, or
- has no annotation (because CONTAINER is the default)

Consequently the method setRollbackOnly() cannot be used if the Session Bean has the annotation @TransactionManagement(TransactionManagementType.BEAN) on the EJB class.

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on container-managed transaction Demarcation
 
Similar Threads
Question about bean-managed transactions
EJB 2 BMT
Question about Transactions in EJB / MDB scenario
Default behaviour of TransactionAttributeType in case TransactionManagementType.CONTAINER
SessionContext . setRollbackOnly() method doubt.