-->
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.  [ 5 posts ] 
Author Message
 Post subject: Multiple SessionFactories or single factory passing db conn?
PostPosted: Mon Jun 20, 2005 11:32 am 
Beginner
Beginner

Joined: Mon Jun 21, 2004 2:41 pm
Posts: 40
Hibernate version: 3.0.5

In our system we currently have 1975 tables for our ERP product. We we deploy the session factory we have to allocate around 128 meg. of PermSize space for the single session factory to be deployed. More if we want to be able to redeploy.

My question is as follows... In order to allow our program(s) to connect to multple databases what is the correct or advised way to do this?

I have read that we should just create another session factory. But the session factories are so expensive and involve a lot of setup overhead for each database even though the schema is likely the same. Steps are:
1) create a copy of the datasource and modify.
2) copy hibernate-service.xml and modify to connect to new datasource name
a. change mbean service name
b. change SessionFactoryName attribute
c. modify ant build file to create 2 Har files and deploy them to Jboss
3) Change code to know which SessionFactory to connect to.
Rinse and repeat for every new database option. More if the tables/schema is different.

Another option is the ability to pass a Connection object to the SessionFactory.openSession(Connection) API. But if you do this do you lose the C3PO connection pooling? I also read that by doing this "but be warned that the 2nd level cache is global for one session factory thus you will not have complete isolation ... so multiple session factories are to be preffered" -- [urlh]ttp://forum.hibernate.org/viewtopic.php?t=942051&highlight=multiple+connection[/url]

Right now we are not explecitly doing anything with the 2nd level cache. Ie. we have not turned it on.
So by my understanding we should us the option of passing the Connection, unless we loose C3PO pooling, instead of creating new sessionFactories.

Thank you for any input,
David


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 8:56 am 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
I doubt you'll get an answer to this question.. I think Hibernate still does not have a suitable solution for this scenario.

With such a large number of tables, it would seem unlikely that a new Session Factory object per database would be appropriate. However, if you pass a connection object or parameter, as you point out, you will lose isolation in the 2nd level cache.

In our situation, one session factory is equally inappropriate. We have a smaller number of tables (only 400) but a large number of databases (2000 and climbing).

I believe we could use hibernate but in its current form, I think we would suffer on flexibility, scalability and performance by doing so.

M.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 11:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You should use one SF instance per database, of course.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 11:57 am 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
Even with 2000+ catalogs / databases? I'm wondering how much memory I would require for this...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 12:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
In the first post you say you have 2000 tables. Now it is 2000 database instances. Which?

How much memory does 2000 database instances consume? Much more than 2000 SessionFactory instances, I would have assumed.


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