Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTA transaction or resource-local transaction.

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume the entity manager below:



Is this EntityManager in JTA transaction or resource-local transaction?

Please help.
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. It depends on how your persistence.xml is configured - the attribute type of element persistence-context determines this. If it is omitted, it defaults to JTA in EE, and to RESOURCE_LOCAL in SE.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is an application managed entity manager. The transaction type depends on the settings in the persistence.xml file:

<persistence-unit name="PU">
<persistence-unit name="PU" transaction-type="JTA">

declare an JTA transaction entity manager (tansaction-type="JTA" is default), while

<persistence-unit name="PU" transaction-type="RESOURCE_LOCAL">

declares a resource-local transaction entity manager.

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Raf and Ralph
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ralph is right, I used wrong names for the element and attribute.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way (with fresh expressions from exam): It's good to have a clear understanding of the various types of entity managers (application managed vs. container managed, JTA vs. resource local transactions) and their persistence contexts (transaction scoped vs. extended).
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ralph Jaus wrote:By the way (with fresh expressions from exam): It's good to have a clear understanding of the various types of entity managers (application managed vs. container managed, JTA vs. resource local transactions) and their persistence contexts (transaction scoped vs. extended).


I agree with this completely! For understanding this, I recommend PRO EJB3 Book, Chapter 5. MUST READ!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic