-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Bulk queries in Hibernate 3.3 + JbossCache 2.1.1 + Bitronix
PostPosted: Wed Dec 03, 2008 7:53 am 
Newbie

Joined: Mon Sep 22, 2008 5:32 am
Posts: 4
An exception is logged when using bulk queries in Hibernate 3.3 + Jboss Cache 2.1.1 + Bitronix 1.3.2

When a bulk query (like “delete from AnEntity”) is executed, JbossCache complains about the current transaction being invalid. Looks like it expects an ACTIVE tx, but the current one is COMMITED.

By poking around into btm, jboss cache and hibernate sources, I saw that hibernate registers a synchronization to be executed after the tx completion. It should clear the cache in case of bulk operations. Hibernate delegates to jboss cache for node deletion but jboss cache looks up whatever there is an ongoing global tx. If it finds one, it checks that it is ACTIVE; if not it throws an exception.

The problem looks similar with this one: http://opensource.atlassian.com/project ... e/HHH-2532 and http://www.jboss.com/index.html?module= ... c&t=103983 and http://forum.hibernate.org/viewtopic.php?t=972301 but I’m using hibernate 3.3 and that issue should be fixed.

The test:
Code:
public class HibernateJbc2Test {

    @Resource
    private TransactionManager bitronixTransactionManager;

    @Resource
    private SessionFactory sessionFactory;

     //not really a test
    @Test
    public void testJbc2() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException {
        bitronixTransactionManager.begin();

        sessionFactory.getCurrentSession().saveOrUpdate(new AnEntity());
        sessionFactory.getCurrentSession().createQuery("delete from " + AnEntity.class.getName()).executeUpdate();
       
        bitronixTransactionManager.commit();
    }

}


The hibernate configuration:
Code:
<hibernate-configuration>
    <session-factory>

        <property name="current_session_context_class">jta</property>
        <property name="transaction.factory_class">bitronix.BitronixJTATransactionFactory</property>
        <property name="transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</property>

        <property name="cache.use_second_level_cache">true</property>
        <property name="cache.region.factory_class">org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory</property>

        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

        <mapping class="hibernate.AnEntity"/>

    </session-factory>
</hibernate-configuration>


The entity:
Code:
@Entity
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
public class AnEntity {

    @Id
    @GeneratedValue
    private Integer id;

    public Integer getId() {
        return id;
    }

}


The cache config:
Code:
<server>
   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" name="jboss.cache:service=Cache"/>
</server>


The exception:
Code:
13:39:05 ERROR (ActionQueue.java:207) - could not release a cache lock
org.hibernate.cache.CacheException: org.jboss.cache.CacheException: Invalid transaction a Bitronix Transaction with GTRID [737072696E672D62746D0000011DFCA4E70800000000], status=COMMITTED, 1 resource(s) enlisted (started Wed Dec 03 13:39:04 EET 2008), status = 3
   at org.hibernate.cache.jbc2.util.CacheHelper.removeAll(CacheHelper.java:380)
   at org.hibernate.cache.jbc2.util.CacheHelper.removeAll(CacheHelper.java:360)
   at org.hibernate.cache.jbc2.access.TransactionalAccessDelegate.evictOrRemoveAll(TransactionalAccessDelegate.java:146)
   at org.hibernate.cache.jbc2.access.TransactionalAccessDelegate.evictAll(TransactionalAccessDelegate.java:142)
   at org.hibernate.cache.jbc2.entity.TransactionalAccess.evictAll(TransactionalAccess.java:102)
   at org.hibernate.impl.SessionFactoryImpl.evictEntity(SessionFactoryImpl.java:870)
   at org.hibernate.action.BulkOperationCleanupAction.evictEntityRegions(BulkOperationCleanupAction.java:153)
   at org.hibernate.action.BulkOperationCleanupAction.afterTransactionCompletion(BulkOperationCleanupAction.java:132)
   at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:198)
   at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:451)
   at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:252)
   at org.hibernate.transaction.CacheSynchronization.afterCompletion(CacheSynchronization.java:117)
   at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:382)
   at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:188)
   at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:96)
   at hibernate.HibernateJbc2Test.testJbc2(HibernateJbc2Test.java:44)

Caused by: org.jboss.cache.CacheException: Invalid transaction a Bitronix Transaction with GTRID [737072696E672D62746D0000011DFCA4E70800000000], status=COMMITTED, 1 resource(s) enlisted (started Wed Dec 03 13:39:04 EET 2008), status = 3
   at org.jboss.cache.interceptors.Interceptor.assertTransactionValid(Interceptor.java:208)
   at org.jboss.cache.interceptors.PessimisticLockInterceptor.lock(PessimisticLockInterceptor.java:428)
   at org.jboss.cache.interceptors.PessimisticLockInterceptor.acquireLocksWithTimeout(PessimisticLockInterceptor.java:399)
   at org.jboss.cache.interceptors.PessimisticLockInterceptor.handleRemoveNodeMethod(PessimisticLockInterceptor.java:274)
   at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:108)
   at org.jboss.cache.interceptors.PessimisticLockInterceptor.invoke(PessimisticLockInterceptor.java:81)
   at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111)
   at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:58)
   at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111)
   at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:456)
   at org.jboss.cache.interceptors.TxInterceptor.handleRemoveNodeMethod(TxInterceptor.java:215)
   at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:108)
   at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111)
   at org.jboss.cache.interceptors.MethodDispacherInterceptor.invoke(MethodDispacherInterceptor.java:58)
   at org.jboss.cache.interceptors.Interceptor.nextInterceptor(Interceptor.java:111)
   at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:73)
   at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:123)
   at org.jboss.cache.invocation.AbstractInvocationDelegate.invoke(AbstractInvocationDelegate.java:64)
   at org.jboss.cache.invocation.CacheInvocationDelegate.removeNode(CacheInvocationDelegate.java:420)
   at org.hibernate.cache.jbc2.util.CacheHelper.removeAll(CacheHelper.java:378)
   ... 43 more


Top
 Profile  
 
 Post subject: Bulk queries in Hibernate 3.3 + JbossCache 2.1.1 + Bitronix
PostPosted: Thu Dec 11, 2008 12:27 pm 
Newbie

Joined: Mon Sep 22, 2008 5:32 am
Posts: 4
Anyone knows what’s going on?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.