0
我想清除緩存(ehcache)並從數據庫中重新加載(我希望這可以手動刷新我們的一些要求)。對於在方法我都用過Ehcache從數據庫按需刷新(手動刷新)
CacheManager.removalAll();
之後,我已經嘗試了兩種方式,但我得到如下所述相同的錯誤(可能是一些錯在這裏)
1)
for (String cacheName : cacheNames) {
cache = lvCacheMgr.addCache(cacheName);
}
2)
for (String cacheName : cacheNames) {
lvCacheMgr.addCache(cacheName);
cache = lvCacheMgr.getCache(name);
cache.initialise();
}
然後我收到錯誤如下
Caused by: java.lang.IllegalStateException: The org.hibernate.cache.StandardQueryCache Cache is not alive.
at net.sf.ehcache.Cache.checkStatus(Cache.java:2199)
at net.sf.ehcache.Cache.get(Cache.java:1354)
at org.hibernate.cache.EhCache.get(EhCache.java:74)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:105)
at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2163)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2126)
at org.hibernate.loader.Loader.list(Loader.java:2096)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)