aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Need understanding on Handling of setRollbackOnly invoked from methods with transaction attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Need understanding on Handling of setRollbackOnly invoked from methods with transaction attribute" Watch "Need understanding on Handling of setRollbackOnly invoked from methods with transaction attribute" New topic
Author

Need understanding on Handling of setRollbackOnly invoked from methods with transaction attribute

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Hi

Source:EJB 3.1 Specfication
13.6.2.8 Handling of setRollbackOnly Method


The container must handle the EJBContext.setRollbackOnlymethod invoked from a business
method executing with the REQUIRED, REQUIRES_NEW, or MANDATORY transaction attribute as follows:

1.The container must ensure that the transaction will never commit. Typically, the container
instructs the transaction manager to mark the transaction for rollback.

2.If the container initiated the transaction immediately before dispatching the business method to
the instance (as opposed to the transaction being inherited from the caller), the container must
note that the instance has invoked the setRollbackOnlymethod. When the business
method invocation completes, the container must roll back rather than commit the transaction.
If the business method has returned normally or with an application exception, the container
must pass the method result or the application exception to the client after the container per-formed the rollback.


Please let me know if my understanding for the statement 2 mentioned above is correct .

1.As stated in the first sentence "container initiated the transaction immediately before dispatching the business method to the instance"

1.Understanding:Does this line means that "container is starting a new transaction as opposed to be inherited from caller" ?

2.As stated in the first sentence"If the business method has returned normally or with an application exception, the container must pass the method result or the application exception to the client after the container performed the rollback "

2.Understanding:If the Business method executed normally,then container passes the method result to caller.Here,result cannot be part of transaction Because if it is a part of transaction then the result will not be obtained as the transaction was rolled-backed.


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

Joined: Apr 07, 2010
Posts: 1733
    
  25

Hi Mohit,

1.Understanding: Does this line means that "container is starting a new transaction as opposed to be inherited from caller" ?

Yes, your understanding is correct.

Understanding:If the Business method executed normally,then container passes the method result to caller.Here,result cannot be part of transaction Because if it is a part of transaction then the result will not be obtained as the transaction was rolled-backed.

Yes, correct. As you notice the caller won't be affected by rolling back the transaction on the called instance as the caller wasn't involved in the transaction from the start.

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: Need understanding on Handling of setRollbackOnly invoked from methods with transaction attribute