I am trying to create multiple cachemanagers in the same JVM using EhCache 2.5.1. Hibernate's EhCacheRegionFactory ignores the cacheManagerName defined in properties, if there is a configurationResourceName defined.
I am using the following code.
configuration.setProperty("net.sf.ehcache.configurationResourceName", defFile);
configuration.setProperty("net.sf.ehcache.cacheManagerName", "ORM"+appName);
The EhCacheRegionFactory from EhCache 2.5.1 does this with
manager = new CacheManager(HibernateUtil.overwriteCacheManagerIfConfigured(configuration, properties));
But the EhCacheRegionFactory provided by Hibernate in 4.1.9 has this ->
Configuration configuration = HibernateUtil.loadAndCorrectConfiguration( url );
manager = new CacheManager( configuration );
Basically, it is missing the part where the configuration is updated based on properties defined.
This will result in an error since EhCache 2.5 does not support multiple cache managers with the same name.
|