• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application managed entity manager

 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
 
Himanshu Chitranshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
yes your understanding is 100% right....
 
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
can you tell me who implements EntityTransaction Interface?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic