openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r708764 - in /openjpa/branches/1.3.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 Wed, 29 Oct 2008 03:48:45 GMT
Author: allee8285
Date: Tue Oct 28 20:48:44 2008
New Revision: 708764

URL: http://svn.apache.org/viewvc?rev=708764&view=rev
Log:
OPENJPA-754 - Add additional condition to determine if the pre/postUpdate callback should
be called.

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

Modified: openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?rev=708764&r1=708763&r2=708764&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ openjpa/branches/1.3.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Tue Oct 28 20:48:44 2008
@@ -976,6 +976,8 @@
             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 +1005,7 @@
                 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) {
@@ -2813,7 +2815,8 @@
             // 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.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java?rev=708764&r1=708763&r2=708764&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
(original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMessageListeners.java
Tue Oct 28 20:48:44 2008
@@ -155,8 +155,16 @@
 
             em.getTransaction().commit();
 
-            // Complete the 2nd @postPersist and the @preUpdate caused by
-            // setters calls in @postPersist
+            // Complete the 2nd @postPersist
+            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, 1, 1, 0, 0, 0);
 
         } finally {



Mime
View raw message