File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes how to make session cache in sync with database ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to make session cache in sync with database ?" Watch "how to make session cache in sync with database ?" New topic
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: 1632
    
    7

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to make session cache in sync with database ?
 
Similar Threads
record cache
Problem with Hibernate Cache
NX:Locking - one data instance or multiple
Stateless SessionBean
Maintaining sessions between ASP & JSP