I am in interested to know if the Hibernate Second-Level caching can be shared between two different Hibernate session running on two different JVM.
I am using Hibernate 3.1 with Ehcache to provide second-level caching, and in the Ehcache.xml config file we can specify where we like to create the cache on the disk
<ehcache>
<diskStore path="C:\Learn\db"/>
</ehcache>
So If I now open two different Hibernate session, in different JVMs where both pointing to the same , will that allow me to share the second-level cache between two JVM.
If this is the case. so if one of the Hibernate session update its cache (session level cache), will the subsequently update the second-level cache and hence the second session running on different JVM when access that cache will get the updated data.
many thanks.
You can use any of the ehcache replication/clustering mechanisms with your Hibernate second level caches. See either:
Now, depending on the which replication/clustering solution you go for, all caching strategies might not be recommended, but at least it wouldn't require a full XA environment.