1 Reply Latest reply on Dec 19, 2011 9:32 AM by gadeyne.bram

    Transaction does not commit before ajax rerender

    gadeyne.bram

      Hi all,


      I'm having an issue regarding transactions.


      My bussiness logic follows this pattern:


      JSF
         -EJB controller(@TransactionAttribute(REQUIRES_NEW), @Stateless, @Scope(SESSION))
            -EJB DAO(@TransactionAttribute(REQUIRED), @Stateless, @Scope(SESSION))


      In these DAO's I update, insert or delete some entities. As far as I know the transaction would be committed when the method in the EJB Controller has been closed (Since the transaction was started there). Now it seems like the transaction does nog commit before the AJAX has rerendered a part of the page. Only when I use a manual refresh (F5) the changes appear in my view.


      Can anyone guide me to what the problem might be?


      I've also tried changing the @TransactionAttribute to @Transactional but this did not seem to resolve the issue. Maybe I should configure something in components.xml?

        • 1. Re: Transaction does not commit before ajax rerender
          gadeyne.bram

          I've set up my DAO objects to use @PersistenceContext in stead of @In so I have better control on when transactions are commited.



          If i'm correct then there is a global transaction by seam. This allows for easy lazyLoading of properties. If I get entities using a entityManager via @PersistenceContext then I get the following exception:


          org.hibernate.LazyInitializationException: could not initialize proxy - no Session


          I guess this is because my statefull session bean receiving the entities has an other instance of a persistenceContext en so can nog lazy load dataproperties from my entities.


          Any thoughts?


          Is there a good way to use Container managed transactions together with Seam managed transactions? Or is there a way to commit a transaction using the seam transaction management?