• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

how to make session cache in sync with database ?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill, for the information, i will go through the links
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic