Hi,
I have a set up in my application wherein we have multiple hibernate.cfg.xml to connect to different databases in same sql server
DatabaseA-hibernate.cfg.xml
DatabaseB-hibernate.cfg.xml
DatabaseC-hibernate.cfg.xml
But just one ehcache.xml with default configuration.
1) Can someone guide me on how to configure second level cache using ehcache , for such scenario. I am getting following warning and not sure if it is because I have not configured separate ehcache for different databases.
WARN net.sf.ehcache.CacheManager:611 - Creating a new instance of CacheManager using the diskStorePath ".......AppData\Local\Temp\" which is already used by an existing CacheManager.
The source of the configuration was net.sf.ehcache.config.generator.ConfigurationSource$DefaultConfigurationSource@2fc07.
The diskStore path for this CacheManager will be set to .....AppData\Local\Temp\\ehcache_auto_created_xyz.
2) Read some of the forums to replace org.hibernate.cache.ehcache.EhCacheRegionFactory with org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory for hibernate.cache.region.factory_class to get rid of above warning
But really want to understand what is the correct configuration. Please advise.
Current configuration:
1) Following jars are used.
hibernate-ehcache-4.3.7.Final.jar
ehcache-core-2.4.3.jar
Hibernate version 4.3.7
2) Not creating CacheManager or adding programatically anything to it. Using all defaults.
Following is the configuration in ehcache.xml
<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="300"
memoryStoreEvictionPolicy="LRU"
/>
<!-- The unnamed query cache -->
<cache
name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="1000"
eternal="false"
timeToLiveSeconds="300"
overflowToDisk="false"
/>
3) Properties in hibernate.cfg.xml for 2nd level cache
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
4) JDK version 1.8
Niks