After migration from Hibernate Ehcache module to Hibernate JCache we are facing the issue with shared CacheManager between different spring contexts in tests. This issue is causing problem when you are trying to access to cache which was closed during shutdown by some spring context.
In Hibernate Ehcache we were using
org.hibernate.cache.ehcache.EhCacheRegionFactory which is working as expected(creates new CacheManager each time), but in Hibernate JCache there is only
org.hibernate.cache.jcache.JCacheRegionFactory which returns same CacheManager whatever SessionFactory is used.
Hibernate userguide is saying:
Example 23. JCache configuration <property name="hibernate.javax.cache.provider" value="org.ehcache.jsr107.EhcacheCachingProvider"/> <property name="hibernate.javax.cache.uri" value="file:/path/to/ehcache.xml"/> Only by specifying the second property `hibernate.javax.cache.uri` will you be able to have a `CacheManager` per `SessionFactory` .
But even we’ve added
hibernate.javax.cache.uri to config we are having same issue. Also, from the source code it’s not clear what is the relation between uri for config and creation of CacheManager per SessionFactory.
Please advise how to deal with this issue.