• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with understanding Transaction Management Demarcation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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





 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
reply
    Bookmark Topic Watch Topic
  • New Topic