Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to control transactions when using container managed Entity Manager

 
varaprasad mutyala
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am recently started using JPA(Java Persistence API) as part of my EJB Application.

and i have one doubt..

I am using Container managed Entity Manager , so am i need to control transactions using begin(), commit(),rollback() methods.

OR will container manages it.

how to handle this...

can you please help me out.

 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is container managed it should be integrated with your server's JTA transaction service. With EJB this will typically mean each SessionBean method will start and end a transaction automatically.

If you want to control the transaction yourself, then don't use a managed EntityManager, instead inject the EntityManagerFactory and obtain your own EntityManager.
 
varaprasad mutyala
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You James,

and sorry for late reply.
now i am clear about this issue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic