Intergation issue with Infinispan 5.1 and hibernate
slorg1 Nov 15, 2011 11:56 AMHi,
I am running into a bit of a pickle integrating the new(er) Beta 4 with hibernate when using the cache as transactional AND autoCommit FALSE.
Caused by: org.hibernate.cache.CacheException: java.lang.IllegalStateException: This is a tx cache!
at org.hibernate.cache.infinispan.util.CacheAdapterImpl.put(CacheAdapterImpl.java:98)
at org.hibernate.cache.infinispan.util.CacheHelper.initInternalEvict(CacheHelper.java:53)
at org.hibernate.cache.infinispan.impl.BaseRegion.establishInternalNodes(BaseRegion.java:83)
at org.hibernate.cache.infinispan.impl.BaseRegion.start(BaseRegion.java:70)
at org.hibernate.cache.infinispan.InfinispanRegionFactory.buildEntityRegion(InfinispanRegionFactory.java:176)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:891)
... 33 more
Caused by: java.lang.IllegalStateException: This is a tx cache!
at org.infinispan.context.TransactionalInvocationContextContainer.createInvocationContext(TransactionalInvocationContextContainer.java:71)
at org.infinispan.CacheImpl.getInvocationContext(CacheImpl.java:432)
at org.infinispan.CacheImpl.getInvocationContextWithImplicitTransaction(CacheImpl.java:420)
at org.infinispan.CacheImpl.put(CacheImpl.java:629)
at org.infinispan.DecoratedCache.put(DecoratedCache.java:297)
at org.hibernate.cache.infinispan.util.CacheAdapterImpl.put(CacheAdapterImpl.java:96)
... 41 more
The issue here is that the cache is set as transactional and when using the EntityManagerFactory from hibernate,
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900)
even though I started a transaction, the org.hibernate.cache.infinispan.impl.BaseRegion suspends the transaction when sending an evict all in the cache (at start up).
That causes the cache to crash (stack trace above), complaining that it is transactional and no transaction exists (logical since it was suspended).
The questions would then be:
Is there a new piece of code for integrating with hibernate (I checked hibernate 4.0.0.CR5 and it is the same code)?
Why does the transaction need to be suspended if the cache is transactional?
Thank you in advance,