openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r494298 - /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Date Tue, 09 Jan 2007 02:00:16 GMT
Author: mprudhom
Date: Mon Jan  8 18:00:15 2007
New Revision: 494298

URL: http://svn.apache.org/viewvc?view=rev&rev=494298
Log:
Make sure we keep the entity's @Version field in sync with any changes to the internal version
of the instance.

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?view=diff&rev=494298&r1=494297&r2=494298
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Mon Jan  8 18:00:15 2007
@@ -575,19 +575,22 @@
     }
 
     public void setVersion(Object version) {
-        _version = version;
         _loadVersion = version;
+        assignVersionField(version);
+    }
+
+    public void setNextVersion(Object version) {
+        assignVersionField(version);
+    }
 
+    private void assignVersionField(Object version) {
+        _version = version;
         FieldMetaData vfield = _meta.getVersionField();
         if (vfield != null)
             store(vfield.getIndex(), JavaTypes.convert(version,
                 vfield.getTypeCode()));
     }
 
-    public void setNextVersion(Object version) {
-        _version = version;
-    }
-
     public PCState getPCState() {
         return _state;
     }
@@ -879,7 +882,7 @@
                 fireLifecycleEvent(LifecycleEvent.AFTER_STORE);
         } else if (reason == BrokerImpl.FLUSH_ROLLBACK) {
             // revert to last loaded version and original oid
-            _version = _loadVersion;
+            assignVersionField(_loadVersion);
             if (isNew() && (_flags & FLAG_OID_ASSIGNED) == 0)
                 _oid = null;
         }
@@ -2492,7 +2495,7 @@
 
             // forget version info and impl data so we re-read next time
             setLoaded(false);
-            _version = null;
+            assignVersionField(null);
             _loadVersion = null;
             if (_fieldImpl != null)
                 Arrays.fill(_fieldImpl, null);



Mime
View raw message