openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1517039 - in /openjpa/branches/1.2.x: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
Date Fri, 23 Aug 2013 21:14:18 GMT
Author: hthomann
Date: Fri Aug 23 21:14:18 2013
New Revision: 1517039

URL: http://svn.apache.org/r1517039
Log:
OPENJPA-754: Add additional condition to determine if the pre/postUpdate callback should be
called - back ported to 1.2.x Albert Lee's trunk changes.

Modified:
    openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
    openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java

Modified: openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?rev=1517039&r1=1517038&r2=1517039&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ openjpa/branches/1.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Fri Aug 23 21:14:18 2013
@@ -976,6 +976,7 @@ public class StateManagerImpl
             boolean wasNew = isNew();
             boolean wasFlushed = isFlushed();
             boolean wasDeleted = isDeleted();
+            boolean needPostUpdate = !(wasNew && !wasFlushed) && (ImplHelper.getUpdateFields(this)
!= null);
 
             // all dirty fields were flushed
             _flush.or(_dirty);
@@ -1003,7 +1004,7 @@ public class StateManagerImpl
                 fireLifecycleEvent(LifecycleEvent.AFTER_PERSIST_PERFORMED);
             else if (wasDeleted)
                 fireLifecycleEvent(LifecycleEvent.AFTER_DELETE_PERFORMED);
-            else 
+            else  if (needPostUpdate)
                 // updates and new-flushed with changes
                 fireLifecycleEvent(LifecycleEvent.AFTER_UPDATE_PERFORMED);
         } else if (reason == BrokerImpl.FLUSH_ROLLBACK) {
@@ -2828,7 +2829,8 @@ public class StateManagerImpl
             // BEFORE_PERSIST is handled during Broker.persist and Broker.attach
             if (isDeleted())
                 fireLifecycleEvent(LifecycleEvent.BEFORE_DELETE);
-            else if (!(isNew() && !isFlushed()))
+            else if (!(isNew() && !isFlushed()) &&
+            		(ImplHelper.getUpdateFields(this) != null))
                 fireLifecycleEvent(LifecycleEvent.BEFORE_UPDATE);
             _flags |= FLAG_PRE_FLUSHED;
         }

Modified: openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java?rev=1517039&r1=1517038&r2=1517039&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
(original)
+++ openjpa/branches/1.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
Fri Aug 23 21:14:18 2013
@@ -156,18 +156,16 @@ public class TestMessageListeners extend
             em.getTransaction().commit();
 
             // Complete the 2nd @postPersist
-            //assertStatus(2, 2, 0, 0, 0, 0, 0);
-            // preUpdate and postUpdate are called in 1.2.x but not in 2.0
-            assertStatus(2, 2, 1, 1, 0, 0, 0);
+            assertStatus(2, 2, 0, 0, 0, 0, 0);
             
             // Make an update to trigger the pre/postUpdater callbacks
             em.getTransaction().begin();
             message = em.find(Message.class,message.getId());
             message.setMessage("Update field and trigger pre/postUpdate");
             em.getTransaction().commit();
-            
+
             // Complete the 2nd @postPersist
-            assertStatus(2, 2, 2, 2, 0, 0, 0);
+            assertStatus(2, 2, 1, 1, 0, 0, 0);
 
         } finally {
             if (em != null && em.getTransaction().isActive())



Mime
View raw message