0 Replies Latest reply on Jan 26, 2011 10:19 AM by Ronaldo Campos

    Keep the same Seam transaction in a conversation

    Ronaldo Campos Newbie

      I have a Seam application with a Flex interface (Exadel Flamingo integration). At some points I need to lock some lines on my database. The problem is that I cant maintain the same transaction (Transaction.instance.getTransaction() or injected) im my conversation. When I perform the lock I have a Transaction instance, but when the Flex application returns the data to my component (in the same conversation) my transaction (and database connction) is not the same anymore, so I can´t commit this transaction becouse my connection is not the owner of the database lock.


      Some information:


      1. Working with a Seam Enterprise project (EAR) and using my components as statefull EJBs it works, but I want to deploy it as a WAR.


      2. I can do it manually, keeping my UserTransaction instance in a local variable at my component, but I didn´t want to do it


      3. My flush mode is MANUAL


      4. I´m sure the flow is all in the same conversation


      5. My componts.xml


      <persistence:entity-manager-factory name="entityManagerFactory"
                            persistence-unit-name="BIC_DAT"/>
      
      <persistence:managed-persistence-context name="entityManager" auto-create="true"
                            entity-manager-factory="#{entityManagerFactory}"/>
      
      <transaction:entity-transaction entity-manager="#{entityManager}" />
      



      The complete application flow:


      1. Start new conversation


      2. Flex requires a entity to Seam application


      3. Seam retrieve the entity from database, lock it and return it to flex


      4. User edit entity on Flex and send it back to seam


      5. Seam app cant commit transaction, because its not the same of the conversation beginning



      Is there any other way to attach a transaction instance to my conversation so a can retrieve always the same instance evem in a different request/event?