This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Problem with understanding Transaction Management Demarcation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Problem with understanding Transaction Management Demarcation" Watch "Problem with understanding Transaction Management Demarcation" New topic
Author

Problem with understanding Transaction Management Demarcation

Mario Wojcik
Greenhorn

Joined: Jan 21, 2010
Posts: 1
Hi

I'm preparing to SCBCD exam and I have problems with understanding various types of Entity Managers.

I know that Application Managed EM can be JTA or ResourceLocal, but what about Transaction Management Demarcation(bean-managed transaction demarcation,or container-managed transaction demarcation) for this type of EM?

For example:
It is possible to be a Resource Local EM with Bean Managed Transactions Demarcation? If yes, how can I mark transaction for rollback(I could use: - UserTransaction.rollback(), UserTransaction.setRollbackOnly(), EntityTransaction.rollback(),EntityTransaction.setRollbackOnly())?


Thanks for help

Mario





Yeray Santana Borges
Ranch Hand

Joined: Mar 02, 2008
Posts: 46
Hi Mario,

Yes, you can use an Resource Local Entity Manager with BMT demarcation. BMT is a different demarcation of a JTA transaction, in my examples codes I can't use EntityManager.joinTransaction() for join the Application Manager-Resource Local Entity Manager transaction to the current JTA. I don't know why, but in my examples when I use EntityManager.joinTransaction with Resource Local I get a exception. Maybe somebody can help us.

Persistence specification 5.5.2 Resource Local Entity Managers:

An entity manager whose transactions are controlled by the application through the EntityTransaction
API is a resource-local entity manager. A resource-local entity manager transaction is mapped
to a resource transaction over the resource by the persistence provider. Resource-local entity managers
may use server or local resources to connect to the database and are unaware of the presence of JTA
transactions that may or may not be active



I understand that the JTA transaction, in this case with BMT demarcation, is unaware by the EntityManager and due to is a Resource Local it can't join the Resource transaction with the current JTA, for that I see this configuration like independent transactions, once JTA BMT transaction and other a Resource Local Transaction. If you want to rollback the JTA transaction you must use UserTransaction.setRollbackOnly(), if you want to rollback the entity operations you must use EntityTransaction.setRollbackOnly().

SCJP 6 - SCWCD 5 - SCBCD 5
 
wood burning stoves
 
subject: Problem with understanding Transaction Management Demarcation