[jboss-cvs] jboss-seam/src/ioc/org/jboss/seam/ioc/spring ...

Michael Youngstrom youngm at gmail.com
Tue May 29 19:20:08 EDT 2007


  User: myoungstrom
  Date: 07/05/29 19:20:08

  Modified:    src/ioc/org/jboss/seam/ioc/spring 
                        SeamManagedEntityManagerFactory.java
  Log:
  Fix for JBSEAM-1365
  
  Revision  Changes    Path
  1.2       +14 -0     jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamManagedEntityManagerFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamManagedEntityManagerFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SeamManagedEntityManagerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- SeamManagedEntityManagerFactory.java	28 Mar 2007 22:46:50 -0000	1.1
  +++ SeamManagedEntityManagerFactory.java	29 May 2007 23:20:08 -0000	1.2
  @@ -8,10 +8,12 @@
   
   import javax.persistence.EntityManager;
   import javax.persistence.EntityManagerFactory;
  +import javax.persistence.TransactionRequiredException;
   
   import org.jboss.seam.Component;
   import org.jboss.seam.log.LogProvider;
   import org.jboss.seam.log.Logging;
  +import org.springframework.transaction.support.TransactionSynchronizationManager;
   import org.springframework.util.ClassUtils;
   
   /**
  @@ -57,6 +59,18 @@
         log.debug("Returning a Seam Managed PC from createEntityManager()");
         SeamLifecycleUtils.beginTransactionalSeamCall();
         EntityManager em = (EntityManager) Component.getInstance(persistenceContextName);
  +      //An extended EntityManager may not join the current Transaction
  +      //because spring may think it's creating a new EntityManager that
  +      //will join the current transaction automatically instead of
  +      //getting an old EntityManager.
  +      if(TransactionSynchronizationManager.isActualTransactionActive()) {
  +         try {
  +            em.joinTransaction();
  +         }
  +         catch (TransactionRequiredException ex) {
  +            log.debug("Could not join JTA transaction because none was active", ex);
  +         }
  +      }
         return (EntityManager) Proxy.newProxyInstance(getClass().getClassLoader(), ClassUtils
                  .getAllInterfaces(em), new SeamManagedPersistenceContextHandler(em));
      }
  
  
  



More information about the jboss-cvs-commits mailing list