Hibernate配置相当于ehcache.xml

时间:2015-03-05 15:29:43

标签: java hibernate caching configuration ehcache

是否有任何Hibernate配置相当于`ehcache.xml?

1 个答案:

答案 0 :(得分:1)

不,没有。 Hibernate EhCacheRegionFactory尝试在加载时加载ehcache.xml配置:

String configurationResourceName = null;
if ( properties != null ) {
    configurationResourceName = (String) properties.get( NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME );
}
if ( configurationResourceName == null || configurationResourceName.length() == 0 ) {
    final Configuration configuration = ConfigurationFactory.parseConfiguration();
    manager = new CacheManager( configuration );
}
else {
    final URL url = loadResource( configurationResourceName );
    final Configuration configuration = HibernateEhcacheUtils.loadAndCorrectConfiguration( url );
    manager = new CacheManager( configuration );
}

可以使用net.sf.ehcache.configurationResourceName属性配置ehcache.xml资源:

net.sf.ehcache.configurationResourceName=/name_of_ehcache.xml