This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes ORM Cache Clearing General Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "ORM Cache Clearing General Question" Watch "ORM Cache Clearing General Question" New topic
Author

ORM Cache Clearing General Question

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I have no real hibernate or ibatis (or any real ORM experience), but I am starting to learn ibatis. I have a general question on ORM caching. My assumption is that the objects are cached in java memory. So...in a typical environment (multiple app servers, one database) how do you clear cache across all app servers programatically?

Example:
2 app servers, serverA and serverB
one object is cached on serverA...we'll call it InventoryList (list of available inventory)
serverA gets a call to updateInventory service which clears cache of InventoryList object on serverA

doesn't serverB still have the cached old object still there (not purged)?

Thanks,
Jim
Arun Rao
Ranch Hand

Joined: Jan 23, 2004
Posts: 41
You ideally would want to cluster the two app servers. Other option would be to retrieve the object from the db every time you do some operation so you are ensured the data is fresh.
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
>>You ideally would want to cluster the two app servers.
I do not understand how that helps. Presumably the cached objects are stored in JVM memory which would not be shared in a cluster (correct me if I'm wrong...but I don't see how it could).

>>Other option would be to retrieve the object from the db every time you do some operation so you are ensured the data is fresh.
Doesn't that defeat the point of caching?

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

James,
The idea is there is memory to memory replication between the clusters. This has efficiency issues of it's own and my or may not be worth the cost.

There are different levels of ORM caching. You can cache within a user transaction without any problem since transactions guarantee that data hasn't changed out from under you. For higher level caching, you can look at data patterns. Is anything known about your data? Maybe some data that is essentially read only and you can cache for a certain amount of time. For example, the list of 50 states.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ORM Cache Clearing General Question
 
Similar Threads
Passing data from servlet/jsp
How to install same application in multiple servers in websphere netdeployment App Server Environmen
Servlet Context
Scope of an HttpSession
distributed caching with ehcache