Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to make session cache in sync with database ?

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let us consider employee obj is there in cache (Session level cache). An external appln. has updated the employee object which is there in session, now how can I make sure that objects in cache are always in sync with database ?

Please provide your thoughts on this.
Do I need to follow any design pattern here ?

Thanks,
Abhishek
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are aware that the data has been altered the 3 methods on session used for managing your session cache that you will want to research and read about are clear, refresh and evict.

This would be an example of evicting an object from the session cache
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#performance-sessioncache

If you have multiple applications writing and reading the same data you will need some sort of version strategy.

This is a decent overview
http://savecode.wordpress.com/2011/03/29/dirty-read-in-hibernate-and-versioning/

I would read this entire chapter from the reference documentation:
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#transactions


 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill, for the information, i will go through the links
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic