-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate and Tomcat - Disabling 2nd level cache
PostPosted: Wed Jan 02, 2013 4:45 am 
Newbie

Joined: Wed Jan 02, 2013 4:31 am
Posts: 1
Hallo!

I'm writing a web application for tomcat using hibernate. I will try to configure hibernate according the step-by-step guide on http://www.ehow.com/how_7999843_stepbystep-hibernate-tomcat-mysql-tutorial.html.
In step 9 the author disables the 2nd level cache. Can one explain, if and why this is really necessary?
In the worst case I would prefer to use a own sessionfactory instance for each user session. I read the 2nd level cache is sessfactory-based. I think disabling the 2nd level cache completely would cause performance disadvantages. Can someone explain the background of this step?

Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate and Tomcat - Disabling 2nd level cache
PostPosted: Thu Jan 03, 2013 7:31 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi FischeFr,

the author there just states
Quote:
Disable Hibernate's second level cache to avoid potential synchronization issues when using with Tomcat


You will have potential synchronization issues, when there co-exist several sessfactories instances working with the same database.
I you just have one Servlet in Tomcat acceding Hibernate (and no other Hibernate-App), then this should not be the case as there will be only one single sessionfactory instance, so you could keep the second level cache enabled.
I guess the author worked with more servlets, so he simply disabled the second level cache.
(there are also ways to synchronize 2nd level caches).
And yes, disabling the 2nd level cache can cause performance disadvantages.


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