-->
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: Using Hibernate for caching
PostPosted: Wed Mar 10, 2004 9:39 am 
Newbie

Joined: Wed Mar 10, 2004 9:07 am
Posts: 2
Location: IN
Hi,

I am trying to find if I can read-through a DB table using Hibernate :

    On Application startup, huge number of records(millions) should be fetched from the database and kept in cache.
    The data is read-only.(Updated only on a weekly basis)


I am thinking of using hibernate to fetch the records. But, I am not sure how to do the Cache Loading. i.e. Reading through the database and putting the objects into the cache. Can this be done or should I iterate through the ResultSet and add the objects manually to the cache?

Thanks a lot for your help.

_________________
Thanks & Regards,

Suresh.R


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 2:17 pm 
Newbie

Joined: Tue Jan 13, 2004 9:13 am
Posts: 2
Suresh,

I am not the most experienced with caching(maybe more experienced users can correct me if I stray). I think you would want to establish a cache provider and in your Entity.hbm.xml file you'd want to set it to read-only. Then upon loading your application, do a session.find("from Entity").

Most likely you'd overflow the heap size of your JVM with this many rows all being cached simultaneously. You'd probably also want to create an ehcache.xml configuration specifying how many you want to keep alive at a time, or if you want to overflow to disk.

All of what I'm saying is covered in the documentation under Performance.

You'll most likely need to experiment with this to find out what works for you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 5:47 am 
Newbie

Joined: Wed Mar 10, 2004 9:07 am
Posts: 2
Location: IN
sball wrote:
Most likely you'd overflow the heap size of your JVM with this many rows all being cached simultaneously. You'd probably also want to create an ehcache.xml configuration specifying how many you want to keep alive at a time, or if you want to overflow to disk.


Thanks for the reply,Pal.
Yes, my jvm will crash if I load the entire resultset into memory. I am trying to figure out, whether I can load the results into a second level cache and use their disk caching feature. From the documents, I could manage to load the entities into query cache. But, even if I specify a CacheProvider for the hibernate.cache.provider_class property, I could see that entities are not being cached. Any pointers on this ?

_________________
Thanks & Regards,

Suresh.R


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.