根据ChssPly76的评论,这是一种从第二级缓存中逐出所有实体的方法(我们可以通过JMX或其他管理工具向管理员公开此方法):
public void evict2ndLevelCache() { try { Map<String, Classmetadata> classesmetadata = sessionFactory.getAllClassmetadata(); for (String entityName : classesmetadata.keySet()) { logger.info("Evicting Entity from 2nd level cache: " + entityName); sessionFactory.evictEntity(entityName); } } catch (Exception e) { logger.logp(Level.SEVERE, "SessionController", "evict2ndLevelCache", "Error evicting 2nd level hibernate cache entities: ", e); }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)