Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: JPA Entity Manager & SessionFactory
PostPosted: Tue Jan 12, 2016 12:26 pm 
Newbie

Joined: Tue Jan 12, 2016 12:16 pm
Posts: 10
Hi

In my project I jave 2 persistence layers (2 jar projets : purpose is to migrate to JPA step by step transparantly).
- Core which uses Hibernate SessionFactory
- Jpa Core which uses EntityManager
Both use an identical jndi datatource
Each has its own Spring context, beans, and transactionManager.

My question is how can I have a transaction manager holding those 2 ?
Other point is we use Tomcat so no JTA.


Top
 Profile  
 
 Post subject: Re: JPA Entity Manager & SessionFactory
PostPosted: Tue Jan 12, 2016 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1515
You cannot do it unless you use JTA. If you use two separate TM, then each one will control a separate database connection and issue the commit/rollback independently. If you share the same database connection, things can go out of sync since a transaction might be attempted to be committed twice, or committed and then rolled back.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: JPA Entity Manager & SessionFactory
PostPosted: Wed Jan 13, 2016 5:12 am 
Newbie

Joined: Tue Jan 12, 2016 12:16 pm
Posts: 10
Thanks for your answer.
As we must use Tomcat (customer contractual request) whereas before we used Wild Fly (with JTA) because of cannot use JTA, so we must migrate functionnalities one by one with all services / daos involved.

Anthony


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.