0 Replies Latest reply on May 31, 2013 5:33 AM by vivien

    concurrency issues on seam managed Hibernate Sessions

    vivien

      Hi Together,

       

      I am running seam 2.2.1 on a jboss 4.2.3 server and do have huge problems during

      concurrent access of component methods , that share the same configured hibernate session resource

      e.g. Web users, that access the webapplication the same time and want to list data of persisted objects (database access)

       

      relevant section inside hibernate.fg.xml:

      ================================

      <property name="hibernate.connection.datasource">java:/TestAppDatasource</property>
      <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
      <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
      <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
          <property name="hibernate.connection.autocommit">false</property>
          <property name="hibernate.transaction.flush_before_completion">true</property>

       

      section in components.xml:

      =====================

      <persistence:managed-hibernate-session name="hibernateSession" auto-create="true" session-factory="#{myhibernateSessionFactory}" />

       

      example code (i do the transaction handling by myself (BMT:Bean managed transaction)

      ================================================================

      the session is injected via

      @In Session hibernateSession;

       

      if (hibernateSession.getTransaction().isActive() == true){

          calledOutsideTransaction = false;

          transaction = hibernateSession.getTransaction();

      }else{

          transaction = hibernateSession.beginTransaction();

      }

       

      HQL/hibernate operations.....

       

      if(calledOutsideTransaction){

          transaction.commit();

      }

       

      The problem is that i get lot of Hibernate exceptions (e.g. Session is close, could not start transaction,....)

       

      Is there i way i have to disable JBOSS CMT (container managed persistence)?

      Do i have to extra configure isolation of hibernate sessions?

       

      Thanks for help! :-)

       

      Br Vivien