wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Caching Database resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Caching Database resultset" Watch "Caching Database resultset" New topic
Author

Caching Database resultset

Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
Hello,

We use hibernate as our JPA implementation provider. I am reading a resultset list using the query below from the database. I would like to cache this data and keep it in session scope, so I dont need to make a call to the database every time I need this data. Please suggest nice way to do this.



-Himalay
Mahesh Trikannad
Ranch Hand

Joined: Dec 14, 2004
Posts: 68
You could use EHCache, with Hibernate.

http://ehcache.org/documentation/hibernate.html


Mahesh Trikannad
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The second level cache will not cache this unless you have configured the query cache, and then it will cache the IDs only.

"Session scope" could mean a bunch of things here. If it s the Hibernate Session, you are already caching there (assuming you load the objects you return from this query into the Hibernate session). If its the EJB session, you can cache the detached objects there easy enough and the same goes for the HTTPSession.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching Database resultset