-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Do I need to use Jboss for multiple session factories?
PostPosted: Wed Aug 03, 2005 9:40 am 
Newbie

Joined: Mon Aug 30, 2004 5:15 pm
Posts: 13
I have made an application for our company intranet using Hibernate3/Tomcat5. Everything works great. I am about to start a second application that will also be using Hibernate. This second application will have it’s own database, but it will also need to read information from the first application’s database. According to all the docs I have read, in order to access multiple databases, I need to create multiple session factories.

I have not used J2EE/Jboss before, but the idea of storing the session factories in JNDI seems to be a clean way to for multiple applications to access multiple session factories.

My question is, do I have to use Jboss in order to store the session factories in JNDI? Or is there an easier way to share session factories in Tomcat?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 11:14 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Your question should be "do I need distributed transactions, that is, a transaction manager that takes care of several resources in a two-phase commit fashion, exposed as a system service with JTA and always available in an EJB container?". If yes, then use JBoss, or any other J2EE system that provides JTA and handles XA resources.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 4:06 pm 
Newbie

Joined: Mon Aug 30, 2004 5:15 pm
Posts: 13
well, I think that is what I need.

I am currently using WebWork for our applications. It uses interceptors to recognize hibernate actions and then grab a hibernate session, start a transaction, do some logic, and then commit the transaction.

In those cases, the transaction is created from the session (session.beginTransaction()), so if I have two sessions (from the two databases), wouldn't I have two transactions? Is there a way to start the transaction first, then do all the hibernate logic? If that is what JTA is for, I obviously needed to be pointed down the newbie path for JTA.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 4:23 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes, this is what JTA/XA/2PC is for. You need to read up on J2EE. I think a good pragmatic approach would be "Mastering EJB" or something that shows you how EJB session bean transaction processing works. There are other solutions that don't require EJB, for example, you could try to get JOTM (a TransactionManager) running in Tomcat with XA Datasources to both your data stores. For Hibernate it's all the same, it _joins_ any global transaction automatically if you use JTATransactionFactory (or in an EJB environment, CMTTransactionFactory). You definitely have to read up on this stuff if you want to use several databases in the same unit of work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.