-->
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: Session Factory Configuration and Session Bean
PostPosted: Fri Apr 16, 2004 3:37 pm 
Beginner
Beginner

Joined: Thu Apr 15, 2004 2:01 pm
Posts: 25
Hi,

In J2EE environment how should I set up Session Factory for best performance? So that it is initialized only once and can be used by Session Beans. Also it is neccessary to close the SessionFactory after each method?

Thanks,
gita


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 8:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Suprisingly, its hard to do in most appservers because of hierarchical class loaders. Typically, each ejb will have its own classloader. Thus, this rules out things like singletons.

I use weblogic 6x, so not sure if this solutions will work on other appservers. I actually use this approach to initialize all kinds of things I only want initialized once for the entire app. What I do is to do all this initialization in a webapp. Webapps have very clean ways of handling this. So I have an ear file containing all my ejb-jars and this war. The way weblogic works (again, can't speak about other appservers) is that the classloader for the war is the parent classloader of the classloaders for the ejbs. Thus you can even perform the initialization as a singleton in the war and have it available to the ejbs.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 9:31 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
In JOnAS, we deploy all our beans in a single ejbjar. This way, we just have a singleton Persistence class that manages the Hibernate SessionFactory and that is shared by all beans.

This may not scale given that generating the interfaces to all beans is really a time-consuming and painful operation, and we may have to split them up. But we have already (for other reasons) verified that we can define a JOnAS startup service, which loads at startup time into the parent classloader, and which can also define the singleton Persistence object at that scope. That works for the entire application server. (Which is fine for us, since our app is the only one on the server, but might not be fine for other environments....)

Cheers,
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 1:13 pm 
Beginner
Beginner

Joined: Thu Apr 15, 2004 2:01 pm
Posts: 25
Thanks for your reply.


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.