File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Clearing L2 Cache using hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Clearing L2 Cache using hibernate" Watch "Clearing L2 Cache using hibernate" New topic

Clearing L2 Cache using hibernate

rudresh kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 83
HI All,

I have configured in such a way that, i run a servlet which pulls the data from database and puts in to the L2 cache and i refer this cache hereafter. Problem is when ever updation is done on the datbase, the only way my L2 cache gets updated is by restarting my server and again running my servlet.
Is there a way to clear the L2 cache. if so is that entire L2 cache will be deleted or is there a way to clear only few object without restarting the server

if possible kindly let me know some examples
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Yes, first when you define your cache regions for the second level cache, you put the level of updating that would occur, I think as the isolation level. This makes the second level cache update when an update occurs, as long as that update occurs in the same application, if some legacy app changes the data, Hibernate will not know that data has changed and your 2l cache will have stale data.

To evict from Second Level cache you use the evict methods on the SessionFactory, it can evict all or single objects.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Clearing L2 Cache using hibernate
jQuery in Action, 3rd edition