-->
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.  [ 3 posts ] 
Author Message
 Post subject: Usage of SessionFactory and Session
PostPosted: Wed Feb 09, 2005 4:28 am 
Newbie

Joined: Wed Feb 09, 2005 4:00 am
Posts: 1
Hello

After reading thru the Reference Doc and Hibernate in Action I'm still a bit unsure regarding the usage of SessionFactory and Session.

Assuming I have a WebApplication (basically a servlet, created with SAP's WebDynpro technology) running unmanaged in an J2EE Application Server (SAP WebAS). This application will be used (hopefully) by many people concurrently.

My question now is: should I create exactly one instance of SessionFactory for my application and Session instances for each caller? If yes - does this (singleton SessionFactory) affect the caching or the result of queries created from Session instances?

OR should I have a SessionFactory for each user that calls my application?

Thanks in advance.

_________________
Regards,
Peter


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 4:57 am 
Beginner
Beginner

Joined: Tue Feb 08, 2005 7:01 am
Posts: 21
You should use at most one factory per web application, and one session for each request. I don't know what do you mean on "affect", but the secondary cache which is also used to cache queries is indeed a factory level thing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 5:46 am 
Newbie

Joined: Wed Sep 01, 2004 9:04 am
Posts: 18
Location: Enschede, Netherlands
You can use more than one SessionFactory in your web application, but that is if you use more than one database.

See the reference documentation (section 3.2):

http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-sessionfactory


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