Is there any Hibernate configuration equivalent of `ehcache.xml?
            Asked
            
        
        
            Active
            
        
            Viewed 748 times
        
    1
            
            
        - 
                    possible duplicate of [Using EhCache in Spring 4 without XML](http://stackoverflow.com/questions/21944202/using-ehcache-in-spring-4-without-xml) – David Lavender Mar 05 '15 at 15:33
 - 
                    I don't think so, because that question was about XML-less configuration of EhCache in **Spring** – hzitoun Mar 05 '15 at 15:36
 
1 Answers
1
            No, there's not. Hibernate EhCacheRegionFactory tries to load the ehcache.xml configuration upon loading:
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 );
}
The ehcache.xml resource can be configured using the net.sf.ehcache.configurationResourceName property:
net.sf.ehcache.configurationResourceName=/name_of_ehcache.xml
        Vlad Mihalcea
        
- 142,745
 - 71
 - 566
 - 911