-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problems with caché refresh
PostPosted: Mon Sep 27, 2010 4:37 am 
Newbie

Joined: Mon Sep 27, 2010 4:23 am
Posts: 2
Hi,

I'm trying to refresh a few rows of a table that have been modified by a third party server. The problem is that hibernate has cached these rows and I can not cool them. I tried this by removing the L2 cache, cleaning the cache with evict, making a clean cache, including closing and reopening the session. The result has always been the same, the cache keeps the old values of rows and does not refresh their values.

Someone could steer a little to get what I want?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Problems with caché refresh
PostPosted: Thu Sep 30, 2010 8:26 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:34 pm
Posts: 24
EntityManagerFactory emf = ResourceManager.getEntityManagerFactory();
Method getSessionFactory = emf.getClass().getMethod("getSessionFactory");
Object sessionFactory = getSessionFactory.invoke(emf);
Method getStatistics = sessionFactory.getClass().getMethod("getStatistics");
Object statistics = getStatistics.invoke(sessionFactory);

out.print("<p>Evict any query result sets cached in the default query cache region.");
Method evictQueries = sessionFactory.getClass().getMethod("evictQueries");
evictQueries.invoke(sessionFactory);
out.print("<br>Done.");

out.print("<p>Evict entities from second-level cache.");
Method getEntityNames = statistics.getClass().getMethod("getEntityNames");
String[] entityNames = (String[]) getEntityNames.invoke(statistics);
Method evictEntity = sessionFactory.getClass().getMethod("evictEntity", String.class);
for(String entityName : entityNames) {
evictEntity.invoke(sessionFactory, entityName);
}
out.print("<br>Done for " + entityNames.length + " entities.");

out.print("<p>Evict all entries from the second-level cache.");
Method getCollectionRoleNames = statistics.getClass().getMethod("getCollectionRoleNames");
String[] collectionRoleNames = (String[]) getCollectionRoleNames.invoke(statistics);
Method evictCollection = sessionFactory.getClass().getMethod("evictCollection", String.class);
for(String collectionRoleName : collectionRoleNames) {
evictCollection.invoke(sessionFactory, collectionRoleName);
}
out.print("<br>Done for " + collectionRoleNames.length + " entries.");

out.print("<p>Evict any query result sets cached in the named query cache region.");
Method getSecondLevelCacheRegionNames = statistics.getClass().getMethod("getSecondLevelCacheRegionNames");
String[] secondLevelCacheRegionNames = (String[]) getSecondLevelCacheRegionNames.invoke(statistics);
evictQueries = sessionFactory.getClass().getMethod("evictQueries", String.class);
for(String secondLevelCacheRegionName : secondLevelCacheRegionNames) {
evictQueries.invoke(sessionFactory, secondLevelCacheRegionName);
}
out.print("<br>Done for " + secondLevelCacheRegionNames.length + " entries.");


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.