Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Tomcat clustering & Hibernate

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currenlty we are using plain old JDBC in our production environment, which is a Tomcat cluster with about 100 concurrent users 24/7 with all kind of applications related to the publishing industry.

For our new application development I would like to introduce Hibernate3 but I'm not aware of the technical implications, or issues, of using Hibernate3 within a clustered environment. Are all parts of Hibernate supported or not or are there some issues that I should be aware of.

Therefore : Does anyone have experience and wrote down some best practices?
for example : what is the best way to store a hibernate.Session
within a clustered environment to prevent opening and closing a
session each time it is used.
[ May 06, 2005: Message edited by: Arnold Reuser ]
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use Hibernate in a clustered environment, you'll probably want to use SwarmCache or JBoss TreeCache. Check this page for more information.

Usually you will create a new Session for each web request. It's not expensive to open up a new Session. SessionFactory objects are expensive to create, so you want to make sure you do that only once.
 
Arnold Reuser
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currenlty we are using OSCache, but from what I've seen now this is not an excellent solution. Which one do you prefer in your environment ( TreeCache or SwarmCache )? I assume in your situation the SessionFactory is cached instead of the Session and not bound to something like ThreadLocal?
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally don't use Hibernate in a clustered environment. So, I wouldn't be able to recommend either one over the other. But, yes, I cache the SessionFactory in my applications and use a servlet filter to open/close the session for each web request. For an example of how I structure my code, you can check out the source code from this article that I wrote.
[ May 06, 2005: Message edited by: James Carman ]
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic