This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic