[jboss-cvs] jboss-seam/src/main/org/jboss/seam/persistence ...

Gavin King gavin.king at jboss.com
Sun Jun 24 15:40:33 EDT 2007


  User: gavin   
  Date: 07/06/24 15:40:33

  Modified:    src/main/org/jboss/seam/persistence    
                        HibernatePersistenceProvider.java
                        ManagedHibernateSession.java
                        ManagedPersistenceContext.java
                        PersistenceProvider.java
  Log:
  fix synchronizations for resource-local txns
  more logging
  
  Revision  Changes    Path
  1.16      +12 -0     jboss-seam/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HibernatePersistenceProvider.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- HibernatePersistenceProvider.java	22 Jun 2007 06:43:30 -0000	1.15
  +++ HibernatePersistenceProvider.java	24 Jun 2007 19:40:33 -0000	1.16
  @@ -61,6 +61,11 @@
         }
      }
      
  +   /**
  +    * Wrap the Hibernate Session in a proxy that supports HQL
  +    * EL interpolation and implements FullTextSession if Hibernate
  +    * Search is available in the classpath.
  +    */
      static Session proxySession(Session session) throws Exception
      {
         if (FULL_TEXT_SESSION_PROXY_CONSTRUCTOR==null)
  @@ -73,6 +78,11 @@
         }
      }
      
  +   /**
  +    * Wrap the delegate Hibernate Session in a proxy that supports HQL
  +    * EL interpolation and implements FullTextSession if Hibernate
  +    * Search is available in the classpath.
  +    */
      @Override
      public Object proxyDelegate(Object delegate)
      {
  @@ -130,6 +140,8 @@
      @Override
      public boolean registerSynchronization(Synchronization sync, EntityManager entityManager)
      {
  +      //TODO: just make sure that a Hibernate JPA EntityTransaction
  +      //      delegates to the Hibernate Session transaction
         getSession(entityManager).getTransaction().registerSynchronization(sync);
         return true;
      }
  
  
  
  1.11      +9 -3      jboss-seam/src/main/org/jboss/seam/persistence/ManagedHibernateSession.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedHibernateSession.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/ManagedHibernateSession.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- ManagedHibernateSession.java	24 Jun 2007 06:34:33 -0000	1.10
  +++ ManagedHibernateSession.java	24 Jun 2007 19:40:33 -0000	1.11
  @@ -1,4 +1,4 @@
  -//$Id: ManagedHibernateSession.java,v 1.10 2007/06/24 06:34:33 gavin Exp $
  +//$Id: ManagedHibernateSession.java,v 1.11 2007/06/24 19:40:33 gavin Exp $
   package org.jboss.seam.persistence;
   
   import java.io.Serializable;
  @@ -22,7 +22,6 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.annotations.intercept.BypassInterceptors;
  -import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.core.Mutable;
   import org.jboss.seam.core.Expressions.ValueExpression;
  @@ -57,6 +56,7 @@
      private List<Filter> filters = new ArrayList<Filter>(0);
      
      private transient boolean synchronizationRegistered;
  +   private transient boolean destroyed;
      
      public boolean clearDirty()
      {
  @@ -132,6 +132,10 @@
      //we can't use @PrePassivate because it is intercept NEVER
      public void sessionWillPassivate(HttpSessionEvent event)
      {
  +      if (synchronizationRegistered)
  +      {
  +         throw new IllegalStateException("cannot passivate persistence context with active transaction");
  +      }
         if ( session!=null && !session.isDirty() )
         {
            session.close();
  @@ -145,6 +149,7 @@
      @Destroy
      public void destroy()
      {
  +      destroyed = true;
         if ( !synchronizationRegistered )
         {
            //in requests that come through SeamPhaseListener,
  @@ -163,7 +168,8 @@
      public void afterCompletion(int status)
      {
         synchronizationRegistered = false;
  -      if ( !Contexts.isConversationContextActive() )
  +      //if ( !Contexts.isConversationContextActive() )
  +      if (destroyed)
         {
            //in calls to MDBs and remote calls to SBs, the 
            //transaction doesn't commit until after contexts
  
  
  
  1.8       +9 -2      jboss-seam/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedPersistenceContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/ManagedPersistenceContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- ManagedPersistenceContext.java	24 Jun 2007 06:34:34 -0000	1.7
  +++ ManagedPersistenceContext.java	24 Jun 2007 19:40:33 -0000	1.8
  @@ -1,4 +1,4 @@
  -//$Id: ManagedPersistenceContext.java,v 1.7 2007/06/24 06:34:34 gavin Exp $
  +//$Id: ManagedPersistenceContext.java,v 1.8 2007/06/24 19:40:33 gavin Exp $
   package org.jboss.seam.persistence;
   
   import java.io.Serializable;
  @@ -55,6 +55,7 @@
      private List<Filter> filters = new ArrayList<Filter>(0);
      
      private transient boolean synchronizationRegistered;
  +   private transient boolean destroyed;
     
      public boolean clearDirty()
      {
  @@ -127,6 +128,10 @@
      //we can't use @PrePassivate because it is intercept NEVER
      public void sessionWillPassivate(HttpSessionEvent event)
      {
  +      if (synchronizationRegistered)
  +      {
  +         throw new IllegalStateException("cannot passivate persistence context with active transaction");
  +      }
         //need to create a context, because this can get called
         //outside the JSF request, and we want to use the
         //PersistenceProvider object
  @@ -152,6 +157,7 @@
      @Destroy
      public void destroy()
      {
  +      destroyed = true;
         if ( !synchronizationRegistered )
         {
            //in requests that come through SeamPhaseListener,
  @@ -170,7 +176,8 @@
      public void afterCompletion(int status)
      {
         synchronizationRegistered = false;
  -      if ( !Contexts.isConversationContextActive() )
  +      //if ( !Contexts.isConversationContextActive() )
  +      if (destroyed)
         {
            //in calls to MDBs and remote calls to SBs, the 
            //transaction doesn't commit until after contexts
  
  
  
  1.17      +3 -0      jboss-seam/src/main/org/jboss/seam/persistence/PersistenceProvider.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PersistenceProvider.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/persistence/PersistenceProvider.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- PersistenceProvider.java	22 Jun 2007 06:43:30 -0000	1.16
  +++ PersistenceProvider.java	24 Jun 2007 19:40:33 -0000	1.17
  @@ -23,6 +23,9 @@
    * optimized for performance and non-standardized features by extending
    * and overriding the methods. 
    * 
  + * The methods on this class are a great todo list for the next rev
  + * of the JPA spec ;-)
  + * 
    * @author Gavin King
    *
    */
  
  
  



More information about the jboss-cvs-commits mailing list