0 Replies Latest reply on Jun 20, 2013 5:02 PM by pzamudio

    Rollback of entities from 2LC not working (JBoss 7.1.1+Hibernate native+Infinispan)

    pzamudio

      Hi. We are working with Hibernate 4.1.10 over JBoss 7.1.1. We are using Infinispan as 2LC. Both Hibernate and Infinispan are configured as modules in JBoss and we intend to use default support of infinispan in JBoss7.

      We get to deploy the application, but we are having some issues in cases where transactions that make changes over a Session (merge of entities, that are flushed to db) are rolledback. The issue is that the changes are kept in 2LC, so when we try to make the changes over the entities again, we get a "org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction".

       

      May be the problem is our configuration of hibernate+infinispan. We follow several tutorials and forums topics, but none of them seem to change the error.

      If we make the same case using JPA insteed of native hibernate, it works fine (i mean, configurating persistence.xml, and using entityManager insteed of hibernate.cfg.xml and SessionFactory).

       

      Our hibernate.cfg.xml:

      <?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>

                            <property name="hibernate.connection.datasource">java:jboss/datasources/testjbpm</property>

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

                          <property name="current_session_context_class">jta</property>

                          <property name="hibernate.cache.use_query_cache">true</property>

                          <property name="hibernate.cache.use_second_level_cache">true</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="javax.persistence.sharedCache.mode">ALL</property>

                          <property name="hibernate.cache.infinispan.use_synchronization">false</property>

                          <property name="hibernate.cache.infinispan.statistics">true</property>

                          <property name="generate_statistics">true</property>

                          <property name="show_sql">true</property>

                          <property name="hibernate.format_sql">false</property>

                          <property name="hbm2ddl.auto">update</property>

                            <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>

                            <property name="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform</property>

                            <property name="hibernate.validator.autoregister_listeners">false</property>

                          <property name="javax.persistence.validation.mode">none</property>

                </session-factory>

      </hibernate-configuration>

       

      I attach an example project with an ee application that exposes an EJB with methods to insert and update an entity and a client project (main) that shows the error.

       

      Any ideas or suggestions are welcome.

      Thanks in advance.

      Pablo