3 Replies Latest reply on May 13, 2014 2:47 AM by Puneet Srivastava

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) annotated method does not run in a separate transaction

    Jan van de klok Newbie

      We run an application with container managed transaction handling.

       

      We have implemented a modeshape persistent storage.

      When a request comes from the browser, a manager class (annotated with @Stateless) handles the request by means of method 'X' . In this manager a transaction is started (which is OK) whne method 'X' is invoked but at some point in the underlying code we call a method that is annotated with

         @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW). This method generates a new id number wich should be stored in the modeshape database. This method is synchronized to avoid generating duplicate numbers.

       

      We would excpect that the @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) causes the container to open a new transaction, generates the new id, and commit that new number to the database.

      Unfortunaltly this does not seem the case, the new generated number not committed (and therefore visible to other sessions) when the @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) annotated method ends.

      It is stored, and visible to other sessions only when method 'X'  ends (which is far too late) and this causes duplicate id's.

       

      We are using JBOSS EAP6.1 with the modeshape module and infinispan as cache. The modeshape usese a postgres database for persisting data.

       

      Can anyone point out what we are missing here??

       

      any help is appreciated

       

      Regards.

       

      Jan van de Klok