It's not a secret anymore!
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

Caching Database resultset

Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324

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.

Mahesh Trikannad
Ranch Hand

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

Mahesh Trikannad
Paul Sturrock

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:
subject: Caching Database resultset
jQuery in Action, 3rd edition