This discussion is archived
2 Replies Latest reply: Jan 9, 2013 7:15 AM by 983682 RSS

Coherence as Hibernate L2 Cache

983682 Newbie
Currently Being Moderated
Hi All,

I'm looking to use Coherence to replicate my hibernate query cache and need some pointer if possible.

The references on the Oracle website is out of date (last update 2010...hibernate3)..

.here's the best that I've found online, cause I'm using hibernate4

My major question is that the comments on

says that it should only be used for there a class that provides this functionality that's production ready?
or will I have to implement some like in the middlewaremagic article above?

thanks in advance


<bean id="sessionFactory"
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>

<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<!--<prop key="hibernate.cache.region.factory_class">cache.CoherenceRegionFactory</prop>-->
<prop key="hibernate.cache.region.factory_class">org.hibernate.testing.cache.CachingRegionFactory</prop>
<prop key="hibernate.cache.provider_class">com.tangosol.coherence.hibernate.CoherenceCacheProvider</prop>

<prop key="hibernate.cache.generate_statistics">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
  • 1. Re: Coherence as Hibernate L2 Cache
    RenévanWijk Oracle ACE
    Currently Being Moderated
    Note that org.hibernate.testing.cache.CachingRegionFactory is just a base example, in which you can put your specific cache API

    For example, the start and stop methods for the cache are still empty
         public void start(Settings settings, Properties properties) throws CacheException {
         public void stop() {
    The Hibernate distribution itself provides implementation for eh-cache (org.hibernate.cache.ehcache.EhCacheRegionFactory) and InfiniSpan (org.hibernate.cache.infinispan.InfinispanRegionFactory).

    From these examples you can build your own implementation for Coherence as was done here:
    The complete code for that example can be found here:
  • 2. Re: Coherence as Hibernate L2 Cache
    983682 Newbie
    Currently Being Moderated
    Thanks René,

    That's a great suggestion about following other implementations (ehcache / infinispan), I'll investigate that more today.

    Also thanks for putting up all your content on, I always learn a lot and you've helped me out on a few occasions.




  • Correct Answers - 10 points
  • Helpful Answers - 5 points