-->
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: Hibernate in Web Services - an effective startup philosophy?
PostPosted: Wed Oct 05, 2005 10:10 am 
Newbie

Joined: Wed Oct 05, 2005 9:51 am
Posts: 5
Hi !

I am implementing a set of web services. Each of them using Hibernate when accessing the database.

The problem is a follows: Everytime a webservice is invoked, Hibernate starts it's initialization of the SessionFactory, reading all the mapping-files etc... Very time consuming.

Is there an easy way to avoid all this startup. That is: Do it once and keep the SessionFactory somewhere until the next time it is needed.

In the Hibernate-doc it says someting like:
"..A SessionFactory is usually only build once, e.g. at startup with a load-on-startup servlet. This also means you should not keep it in an instance variable in your servlets, but in some other location"

Sounds like a good thought, but I have not found any examples on how this is done.

Do anyone have any ideas on how to solve my problem??

Thanks!

Ted


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 10:31 am 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
Two options that I have used with different application are:
- a singleton instance of the session factory. (using a custom factory or delegating to an IOC container like Spring).
- JNDI - supported in by hibernate through configuration file.

What app server are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 10:36 am 
Newbie

Joined: Wed Oct 05, 2005 9:51 am
Posts: 5
Hi !
The app server is JBoss 4.0.2.

Thank you for you suggestions.
Do you also now if there are any examples available for the two approaches anywhere..?

Ted


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 10:32 am 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:25 am
Posts: 36
Take a look at the following:

http://www.laliluna.de/first-hibernate- ... orial.html
http://hibernate.org/42.html

There are a lot of examples on the Hibernate and Spring sites.


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.