Ehcache缓存的清理问题

来源:互联网 发布:江南网络教育 编辑:程序博客网 时间:2024/03/29 04:35

由于项目用到了hibernate的二级缓存 Ehcache,

当系统做数据库还原时又是用Runtime执行的命令,

所以导致当数据库还原后页面数据并没有及时更新,

因此想用以下代码清除缓存

CacheManager singletonManager=CacheManager.getInstance();singletonManager.clearAll();singletonManager.shutdown();


 

但是清除后报错

No row with the given identifier exists


最后还是看了老外的解决方法

sessionFactory.evictQueries()
在导完数据后只要执行上句代码就没有问题了,当然sessionFactory还是要获取一下