Enabling 2n Level Caching: EhCache
Status: Alpha
Brought to you by:
aweisser
EhCacheProvider uses a CacheManager to create instances of net.sf.ehcache.Cache wrapped by org.hibernate.cache.EhCache.
The problem is that the CacheManager reuses the Cache instances. So every time we call EhCacheProvider.buildCache we become a new instance of EhCache delegating to shared net.sf.ehcache.Cache instances. This behavior is not DynamicDataSource aware.
One solution could be to somehow inject a custom CacheManager....
There is a small difference between net.sf.ehcache.hibernate.EhCacheProvider and org.hibernate.cache.EhCacheProvider. The second is the one that wraps a Cache with an EhCache instance...Both use the same CacheManager logic, that reuses the Cache instances.