Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Application managed entity manager

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to understand at what point transaction starts in application managed entity manager. Is it started when we create entity manager or when we invoke some api on entity manager?

In some of the examples I have seen the use of Entity Transaction API to mark the transaction but in the above code we are not making use of that.
are both the approach valid?


Thanks,
Krishan
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
transaction will start when we call begin() method of EntityTransaction class....you can get the reference of EntityTransaction by calling em.getTransaction() method...if you want that em will join the transaction that you have created then you have to call em.joinTransaction().....


 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As application managed entity manager is always extended, so it will queue all the changed to entities unless the transaction is started. So, is it that persistence context which will be created when we create entity manager will be managing those changes but it will not be associated with any transaction. the moment we start transaction by calling trans.begin, persistence context will be synchronized with transaction and at the time of commit persistence context will be flused.

Please tell if my understanding is correct.


thanks,
krishan
 
Himanshu Chitranshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes your understanding is 100% right....
 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
can you tell me who implements EntityTransaction Interface?
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic