-->
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.  [ 6 posts ] 
Author Message
 Post subject: Session Level Cache configuration and purging
PostPosted: Fri Jan 27, 2006 1:27 pm 
Newbie

Joined: Thu May 20, 2004 6:34 pm
Posts: 8
All:
I am working on a reporting application that maintains an open Hibernate Session across multiple HTTP requests.
The session cache appears to be unbounded in size: if enough data is requested from the database, then I get an OOM error in my application and it's because the Session cache is never purged of older data (AFAICS).
Is this expected behavior? I want to go into this application and reimplement with shorter Hibernate Sessions (probably one per request) and a second level cache. I believe that will be a much superior approach. But even then I'm concerned that enough data can be requested as a result of a single HTTP request that the session cache could trigger an OOM (this is a data mining application).
So I need a short term solution to my OOM problem with the session level cache. Is there any workaround or reconfiguration to the Hibernate Session Cache that I can make?

Thanks in advance,
Frank Kurzawa


Hibernate version:3

Mapping documents:

Code between sessionFactory.openSession() and session.close():
Lots and lots of data is retrieved from the database.


Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9i


The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
Frank Kurzawa


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 4:57 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
You can configure the ehcache or one of the other to suite your needs. You can also configure the life time of cached instances. Read about ehcache on their website or in the wiki.

I do not know the size of your base data, but it will be hard to hold a lot of data in the cache. You may consider to use Hibernate on database views.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 5:26 pm 
Newbie

Joined: Thu May 20, 2004 6:34 pm
Posts: 8
Hi Sebastion,
We will be running a second level cache soon. But we are having a problem with the Session (first level) cache, which does not seem to be bounded or have any mechanism for removing data. It just seems to grow as big as the data that is requested.
Is this behavior modifiable? Aside from calling session.evict() on individual objects?

Thanks,

Frank

_________________
Frank Kurzawa


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 5:36 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
You are missusing the session. It is not intended as long running object and as far as I know there is nothing like the functions you are looking for in the session.

You must go for a second level cache. The configuration is very simply and should take you much time.

Regards Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 5:42 pm 
Newbie

Joined: Wed Feb 23, 2005 1:02 pm
Posts: 13
Location: Sacramento, CA
In V3 Why not use SessionFactory.evict(class) to clear 2nd level out?

_________________
-Joel Thompson

http://www.rhinosystemsinc.com
Specializing in Oracle, Java and J2EE Systems for Unix and Windows platforms


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 8:48 pm 
Newbie

Joined: Thu May 20, 2004 6:34 pm
Posts: 8
Thanks, LaLiLuna.
I agree the session level cache is being unused. It was my predecessor but that is cold comfort when we are already on a tight deadline.
We will be seeing about getting the 2nd level cache in there as soon as possible.

Regards,

Frank

_________________
Frank Kurzawa


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