I've been trying to use Infinispan as a second level cache and am having trouble getting it to participate in a transaction. Originally I thought my problem was with Infinispan so I posted a question on the Infinispan forum. You can see the full details here:
https://community.jboss.org/message/819697
I was working with this page (among others) to try to get this working:
https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider
It specifically mentions the need to set hibernate.transaction.manager_lookup_class and hibernate.transaction.factory_class. Which I have been doing:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="TestPersistenceUnit">
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.generate_statistics">false</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.cache.region.factory_class">org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory</property>
<property name="hibernate.cache.infinispan.cachemanager">java:jboss/infinispan/container/hibernate</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
<class-cache class="com.testpackage.entity.MyEntity"
include="all" usage="transactional" />
</session-factory>
</hibernate-configuration>
Eventually in a moment of frustration I tried changing these values to nonsense to see if they were actually doing anything:
Code:
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookupblah</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactoryblah</property>
And the app deployed and worked just fine which surprised me (still didn't participate in transactions though).
Do I have the correct configuration in my original hibernate config to use Infinispan in a transactional manner as my second level cache provider?