Ranjith
Ranjith

Reputation: 23

Query cache using infinispan

In my project I am using Jboss AS 7.1 server, hibernate 3.5 and java 1.7. For cache I am using infinispan 5.1.5 ("Brahma").By the following way I am configuring the cache in hibernate config xml.

<prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.infinispan.InfinispanRegionFactory</prop> <prop key="hibernate.cache.infinispan.statistics">true</prop> <prop key="hibernate.cache.infinispan.cfg">infinispan-config.xml</prop>

and in my infinispan-config.xml

<default>
     <transaction
            transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
            syncRollbackPhase="false"
            syncCommitPhase="false"
            cacheStopTimeout="30000"
            use1PcForAutoCommitTransactions="false"
            autoCommit="true"
            lockingMode="OPTIMISTIC"
            useSynchronization="false"
            transactionMode="TRANSACTIONAL"
     />
     <invocationBatching enabled="true" />
    <loaders passivation="true" shared="true" preload="true">
        <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true"
            ignoreModifications="false" purgeOnStartup="false">
            <properties>
                <property name="location" value="/tmp/infinispan"/>
            </properties>
        </loader>
    </loaders> 
</default> 

My questions:

  1. How can I cache the queries which is used in the java class?
  2. For hibernate hbm files the cache folder was created by infinispan, but cache file is not generated in the respective folder why?

Upvotes: 2

Views: 3960

Answers (1)

Galder Zamarre&#241;o
Galder Zamarre&#241;o

Reputation: 5187

That Infinispan configuration is all over the place and in no way follows the guidelines in the default Infinispan configuration for Hibernate 2LC. There's no need for passivation, it's just a cache! Hibernate itself is already your backend where data can be retrieved if not in the cache. No need for invocation catching and do not configure transactions at the Infinispan config level. Make sure transactions are configured correctly at the Hibernate level and those settings will be used in Infinispan.

Finally, I've created some demos for Hibernate 2LC with Infinispan here. Have a look at them where you'll see how you can do query caching :)

Upvotes: 4

Related Questions