| Author |
how to make session cache in sync with database ?
|
Abhishek Reddy
Ranch Hand
Joined: Mar 28, 2006
Posts: 259
|
|
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
|
Abhishek
|
 |
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
|
|
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
|
[How To Ask Questions][Read before you PM me]
|
 |
Abhishek Reddy
Ranch Hand
Joined: Mar 28, 2006
Posts: 259
|
|
|
Thanks Bill, for the information, i will go through the links
|
 |
 |
|
|
subject: how to make session cache in sync with database ?
|
|
|