1 Reply Latest reply on Jan 22, 2008 11:37 AM by Fady Matar

    Disabling Seam Transaction Managment and Acquiring Entity Ma

    Fady Matar Novice

      I'm adding new features to an application and those features are implemented in JBoss Seam. The existing application uses Hibernate / JSF and has its own way of handling its persistence.

      The additional seam features require a managed persistence context defined in components.xml

      Whenever I disable the transaction management within seam, the old features of the application work fine however I can no longer get hold of the entity manager or persistence context.

      Whenever I enable the seam transaction management I can perform all the persistence functions however, the old features will always throw an exception indicating that the persistence service cannot be closed coming up to the root
      exception:

      You cannot commit with autocommit set!


      Now my question is this, how can I disable the seam transaction management and still get hold of the entity manager?



        • 1. Re: Disabling Seam Transaction Managment and Acquiring Entit
          Fady Matar Novice

          The problem was solved by following this approach:

          Changes in components.xml

          <core:init debug="@debug@" jndi-pattern="@jndiPattern@" transaction-management-enabled="false" />
          
          <transaction:ejb-transaction/>
          


          Now I can use the @PersistentContext from within the application, but what if I want to use the entity manager because I would like to reduce the amount of usage of EJBs. Ideally I would want to inject the entity manager such as:
          @In ("entityManager")
          EntityManager em;
          


          Any hints on this?