cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r454016 - in /incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src: cayenne/java/org/apache/cayenne/ cayenne/java/org/apache/cayenne/access/ tests/java/org/apache/cayenne/access/
Date Sat, 07 Oct 2006 20:47:40 GMT
Author: aadamchik
Date: Sat Oct  7 13:47:39 2006
New Revision: 454016

URL: http://svn.apache.org/viewvc?view=rev&rev=454016
Log:
applying patches for CAY-565, CAY-652 and CAY-653 to 2.0 branch

Modified:
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/CayenneContext.java
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataContext.java
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataDomainQueryAction.java
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataRowStore.java
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ObjectResolver.java
    incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/DataContextSerializationTst.java

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/CayenneContext.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/CayenneContext.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/CayenneContext.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/CayenneContext.java
Sat Oct  7 13:47:39 2006
@@ -432,9 +432,11 @@
 
         Persistent object = (Persistent) descriptor.createObject();
 
-        object.setPersistenceState(PersistenceState.NEW);
-        object.setObjectContext(this);
+        // must follow this exact order of property initialization per CAY-653, i.e. have
+        // the id and the context in place BEFORE setPersistence is called
         object.setObjectId(id);
+        object.setObjectContext(this);
+        object.setPersistenceState(PersistenceState.NEW);
 
         descriptor.injectValueHolders(object);
         graphManager.registerNode(object.getObjectId(), object);

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataContext.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataContext.java
Sat Oct  7 13:47:39 2006
@@ -382,6 +382,7 @@
      * @since 1.2
      */
     public DataChannel getChannel() {
+        awakeFromDeserialization();
         return channel;
     }
 

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataDomainQueryAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataDomainQueryAction.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataDomainQueryAction.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataDomainQueryAction.java
Sat Oct  7 13:47:39 2006
@@ -134,22 +134,6 @@
                 if (oidQuery.isFetchAllowed()) {
 
                     runQueryInTransaction();
-
-                    List result = response.firstList();
-                    if (result != null && !result.isEmpty()) {
-
-                        if (result.size() > 1) {
-                            throw new CayenneRuntimeException(
-                                    "More than 1 row found for ObjectId "
-                                            + oidQuery.getObjectId()
-                                            + ". Fetch matched "
-                                            + result.size()
-                                            + " rows.");
-                        }
-
-                        // cache for future use
-                        cache.snapshots.put(oidQuery.getObjectId(), result.get(0));
-                    }
                 }
                 else {
                     response = new ListResponse();

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataRowStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataRowStore.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataRowStore.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/DataRowStore.java
Sat Oct  7 13:47:39 2006
@@ -233,53 +233,55 @@
         Map modified = null;
         Object eventPostedBy = null;
 
-        for (int i = 0; i < size; i++) {
-            Persistent object = (Persistent) objects.get(i);
-
-            // skip HOLLOW objects as they likely were created from partial snapshots
-            if (object.getPersistenceState() == PersistenceState.HOLLOW) {
-                continue;
-            }
+        synchronized (this) {
+            for (int i = 0; i < size; i++) {
+                Persistent object = (Persistent) objects.get(i);
+
+                // skip HOLLOW objects as they likely were created from partial snapshots
+                if (object.getPersistenceState() == PersistenceState.HOLLOW) {
+                    continue;
+                }
 
-            ObjectId oid = object.getObjectId();
+                ObjectId oid = object.getObjectId();
 
-            // add snapshots if refresh is forced, or if a snapshot is
-            // missing
+                // add snapshots if refresh is forced, or if a snapshot is
+                // missing
 
-            DataRow cachedSnapshot = (DataRow) this.snapshots.get(oid);
-            if (refresh || cachedSnapshot == null) {
+                DataRow cachedSnapshot = (DataRow) this.snapshots.get(oid);
+                if (refresh || cachedSnapshot == null) {
 
-                DataRow newSnapshot = (DataRow) snapshots.get(i);
-
-                if (cachedSnapshot != null) {
-                    // use old snapshot if no changes occurred
-                    if (object instanceof DataObject
-                            && cachedSnapshot.equals(newSnapshot)) {
-                        ((DataObject) object).setSnapshotVersion(cachedSnapshot
-                                .getVersion());
-                        continue;
+                    DataRow newSnapshot = (DataRow) snapshots.get(i);
+
+                    if (cachedSnapshot != null) {
+                        // use old snapshot if no changes occurred
+                        if (object instanceof DataObject
+                                && cachedSnapshot.equals(newSnapshot)) {
+                            ((DataObject) object).setSnapshotVersion(cachedSnapshot
+                                    .getVersion());
+                            continue;
+                        }
+                        else {
+                            newSnapshot.setReplacesVersion(cachedSnapshot.getVersion());
+                        }
                     }
-                    else {
-                        newSnapshot.setReplacesVersion(cachedSnapshot.getVersion());
+
+                    if (modified == null) {
+                        modified = new HashMap();
+                        eventPostedBy = object.getObjectContext().getGraphManager();
                     }
-                }
 
-                if (modified == null) {
-                    modified = new HashMap();
-                    eventPostedBy = object.getObjectContext().getGraphManager();
+                    modified.put(oid, newSnapshot);
                 }
-
-                modified.put(oid, newSnapshot);
             }
-        }
 
-        if (modified != null) {
-            processSnapshotChanges(
-                    eventPostedBy,
-                    modified,
-                    Collections.EMPTY_LIST,
-                    Collections.EMPTY_LIST,
-                    Collections.EMPTY_LIST);
+            if (modified != null) {
+                processSnapshotChanges(
+                        eventPostedBy,
+                        modified,
+                        Collections.EMPTY_LIST,
+                        Collections.EMPTY_LIST,
+                        Collections.EMPTY_LIST);
+            }
         }
     }
 
@@ -412,14 +414,14 @@
     /**
      * Registers a list of snapshots with internal cache, using a String key.
      */
-    public void cacheSnapshots(String key, List snapshots) {
+    public synchronized void cacheSnapshots(String key, List snapshots) {
         snapshotLists.put(key, snapshots);
     }
 
     /**
      * Returns a list of previously cached snapshots.
      */
-    public List getCachedSnapshots(String key) {
+    public synchronized List getCachedSnapshots(String key) {
         if (key == null) {
             return null;
         }

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ObjectResolver.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ObjectResolver.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ObjectResolver.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/access/ObjectResolver.java
Sat Oct  7 13:47:39 2006
@@ -94,9 +94,7 @@
      */
     List synchronizedObjectsFromDataRows(List rows) {
         synchronized (context.getObjectStore()) {
-            synchronized (context.getObjectStore().getDataRowCache()) {
-                return objectsFromDataRows(rows);
-            }
+            return objectsFromDataRows(rows);
         }
     }
 

Modified: incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/DataContextSerializationTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/DataContextSerializationTst.java?view=diff&rev=454016&r1=454015&r2=454016
==============================================================================
--- incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/DataContextSerializationTst.java
(original)
+++ incubator/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/tests/java/org/apache/cayenne/access/DataContextSerializationTst.java
Sat Oct  7 13:47:39 2006
@@ -36,6 +36,10 @@
 
     private static Logger logObj = Logger.getLogger(DataContextSerializationTst.class);
 
+    protected void setUp() throws Exception {
+        fixSharedConfiguration();
+    }
+
     protected void fixSharedConfiguration() {
         // for context to deserialize properly,
         // Configuration singleton must have the right default domain
@@ -49,7 +53,6 @@
     }
 
     public void testSerializeResolver() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithSharedCache();
 
@@ -60,8 +63,18 @@
         assertSame(context.getEntityResolver(), deserializedContext.getEntityResolver());
     }
 
+    public void testSerializeChannel() throws Exception {
+
+        DataContext context = createDataContextWithSharedCache();
+
+        DataContext deserializedContext = (DataContext) Util
+                .cloneViaSerialization(context);
+
+        assertNotNull(deserializedContext.getChannel());
+        assertSame(context.getChannel(), deserializedContext.getChannel());
+    }
+
     public void testSerializeWithSharedCache() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithSharedCache();
 
@@ -84,7 +97,6 @@
     }
 
     public void testSerializeWithLocalCache() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithLocalCache();
 
@@ -109,7 +121,6 @@
     }
 
     public void testSerializeNew() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithSharedCache();
 
@@ -136,7 +147,6 @@
     }
 
     public void testSerializeCommitted() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithSharedCache();
 
@@ -178,7 +188,6 @@
     }
 
     public void testSerializeModified() throws Exception {
-        fixSharedConfiguration();
 
         DataContext context = createDataContextWithSharedCache();
 



Mime
View raw message