7 Replies Latest reply on Aug 29, 2011 9:25 PM by Scott Marlow

    Getting entitymanager delegate causes exception

    Nicklas Karlsson Master

      When I try setting my extended PC entityManager (Hibernate) to manual flush mode with something like

       



      Session session = (Session) entityManager.getDelegate();


      session.setFlushMode(FlushMode.MANUAL);

       

       

      I end up with

       

       

      javax.ejb.EJBException: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it.  This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context.  See JPA spec 2.0 section 7.6.3.1.  Scoped persistence unit name=OSTi-3.0.0-SNAPSHOT.war#OSTi, persistence context already in transaction =org.hibernate.ejb.EntityManagerImpl@700ad2e, extended persistence context =ExtendedEntityManager [OSTi-3.0.0-SNAPSHOT.war#OSTi]

       

      10:57:31,154 ERROR [stderr] (http--127.0.0.1-8080-6)           at org.jboss.as.jpa.container.ExtendedEntityManager.getEntityManager(ExtendedEntityManager.java:88)

       

      10:57:31,154 ERROR [stderr] (http--127.0.0.1-8080-6)           at org.jboss.as.jpa.container.AbstractEntityManager.getDelegate(AbstractEntityManager.java:465)

       

      The error message is pretty detailed in what is going on but it worked fine in AS6, has the rule only been inforced recently?. How should setting the manual flush mode be done? I have a feeling that the problem could be in Seam Faces/Persistence that might be doing some transaction-wrapping in the JSF lifecycle...