• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Caching Database resultset

 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use EHCache, with Hibernate.

http://ehcache.org/documentation/hibernate.html
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic