cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r454062 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/ main/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/ test/java/org/apache/cayenne/access/
Date Sun, 08 Oct 2006 01:51:23 GMT
Author: aadamchik
Date: Sat Oct  7 18:51:21 2006
New Revision: 454062

URL: http://svn.apache.org/viewvc?view=rev&rev=454062
Log:
CAY-680, first pass

Added:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneDataObject.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObject.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainSyncBucket.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectResolver.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectFlattenedRelTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectInCtxtTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectSerializationTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/MeaningfulFKTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/PregeneratedPKTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextRefreshingTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSerializationTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataRowUtilsTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/NestedDataContextReadTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/TransactionThreadTst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneDataObject.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneDataObject.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneDataObject.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/CayenneDataObject.java Sat Oct  7 18:51:21 2006
@@ -67,6 +67,8 @@
      * Returns a DataContext that holds this object. Object becomes assocaiated with a
      * DataContext either when the object is fetched using a query, or when a new object
      * is registered explicitly with a DataContext.
+     * 
+     * @deprecated since 3.0 use {@link #getObjectContext()}.
      */
     public DataContext getDataContext() {
         if (objectContext == null || objectContext instanceof DataContext) {
@@ -78,7 +80,9 @@
     }
 
     /**
-     * Initializes DataObject's persistence context.
+     * Sets object DataContext.
+     * 
+     * @deprecated since 3.0 use {@link #setObjectContext(ObjectContext)}.
      */
     public void setDataContext(DataContext dataContext) {
         this.objectContext = dataContext;
@@ -260,6 +264,7 @@
 
         // call 'recordArcCreated' AFTER readProperty as readProperty ensures that this
         // object fault is resolved
+       // getObjectContext().getGraphManager().
         getDataContext().getObjectStore().recordArcCreated(
                 this,
                 value.getObjectId(),
@@ -321,10 +326,10 @@
             return;
         }
         else if (this.getObjectContext() == null && dataObject.getObjectContext() != null) {
-            dataObject.getDataContext().registerNewObject(this);
+            dataObject.getObjectContext().registerNewObject(this);
         }
         else if (this.getObjectContext() != null && dataObject.getObjectContext() == null) {
-            this.getDataContext().registerNewObject(dataObject);
+            this.getObjectContext().registerNewObject(dataObject);
         }
         else {
             throw new CayenneRuntimeException(
@@ -508,7 +513,7 @@
      */
     protected void validateForSave(ValidationResult validationResult) {
 
-        ObjEntity objEntity = getDataContext().getEntityResolver().lookupObjEntity(this);
+        ObjEntity objEntity = getObjectContext().getEntityResolver().lookupObjEntity(this);
         if (objEntity == null) {
             throw new CayenneRuntimeException(
                     "No ObjEntity mapping found for DataObject " + getClass().getName());
@@ -689,7 +694,7 @@
      * @since 1.2
      */
     public void encodeAsXML(XMLEncoder encoder) {
-        EntityResolver er = getDataContext().getEntityResolver();
+        EntityResolver er = getObjectContext().getEntityResolver();
         ObjEntity object = er.lookupObjEntity(getClass());
 
         String[] fields = this.getClass().getName().split("\\.");

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObject.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObject.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObject.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/DataObject.java Sat Oct  7 18:51:21 2006
@@ -33,11 +33,15 @@
     /**
      * Returns a data context this object is registered with, or null if this object has
      * no associated DataContext.
+     * 
+     * @deprecated since 3.0 use {@link #getObjectContext()}.
      */
     public DataContext getDataContext();
 
     /**
      * Sets object DataContext.
+     * 
+     * @deprecated since 3.0 use {@link #setObjectContext(ObjectContext)}.
      */
     public void setDataContext(DataContext ctxt);
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContext.java Sat Oct  7 18:51:21 2006
@@ -544,7 +544,7 @@
 
         // for a HOLLOW object return snapshot from cache
         if (object.getPersistenceState() == PersistenceState.HOLLOW
-                && object.getDataContext() != null) {
+                && object.getObjectContext() != null) {
 
             return getObjectStore().getSnapshot(object.getObjectId());
         }
@@ -723,8 +723,10 @@
         // this will initialize to-many lists
         descriptor.injectValueHolders(dataObject);
 
+        // note that the order of initialization of persistence artifacts below is
+        // important - do not change it lightly
         dataObject.setObjectId(new ObjectId(objEntityName));
-        dataObject.setDataContext(this);
+        dataObject.setObjectContext(this);
         dataObject.setPersistenceState(PersistenceState.NEW);
         getObjectStore().recordObjectCreated(dataObject);
 
@@ -1542,7 +1544,7 @@
             Iterator it = objectStore.getObjectIterator();
             while (it.hasNext()) {
                 DataObject object = (DataObject) it.next();
-                object.setDataContext(this);
+                object.setObjectContext(this);
             }
         }
     }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataContextDeleteAction.java Sat Oct  7 18:51:21 2006
@@ -73,12 +73,12 @@
 
         DataObject dataObject = (DataObject) object;
 
-        if (dataObject.getDataContext() == null) {
+        if (dataObject.getObjectContext() == null) {
             throw new CayenneRuntimeException(
                     "Attempt to delete unregistered non-TRANSIENT object: " + object);
         }
 
-        if (dataObject.getDataContext() != dataContext) {
+        if (dataObject.getObjectContext() != dataContext) {
             throw new CayenneRuntimeException(
                     "Attempt to delete object regsitered in a different DataContext. Object: "
                             + object
@@ -116,7 +116,7 @@
 
         dataContext.getObjectStore().objectsUnregistered(
                 Collections.singletonList(object));
-        object.setDataContext(null);
+        object.setObjectContext(null);
     }
 
     private void processDeleteRules(DataObject object, int oldState)

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainFlushAction.java Sat Oct  7 18:51:21 2006
@@ -51,6 +51,7 @@
 class DataDomainFlushAction {
 
     private final DataDomain domain;
+    private DataContext context;
     private Map changesByObjectId;
 
     private CompoundDiff resultDiff;
@@ -72,6 +73,10 @@
     DataDomain getDomain() {
         return domain;
     }
+    
+    DataContext getContext() {
+        return context;
+    }
 
     Collection getResultDeletedIds() {
         return resultDeletedIds;
@@ -113,6 +118,8 @@
                     + changes.getClass().getName());
         }
 
+        this.context = context;
+        
         // ObjectStoreGraphDiff contains changes already categorized by objectId...
         this.changesByObjectId = ((ObjectStoreGraphDiff) changes).getChangesByObjectId();
         this.insertBucket = new DataDomainInsertBucket(this);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainSyncBucket.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainSyncBucket.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainSyncBucket.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainSyncBucket.java Sat Oct  7 18:51:21 2006
@@ -163,7 +163,7 @@
                     DataObject object = (DataObject) objects.next();
                     ObjectId id = object.getObjectId();
 
-                    DataRow dataRow = object.getDataContext().currentSnapshot(object);
+                    DataRow dataRow = parent.getContext().currentSnapshot(object);
                     dataRow.setReplacesVersion(object.getSnapshotVersion());
                     object.setSnapshotVersion(dataRow.getVersion());
 

Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java?view=auto&rev=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java (added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java Sat Oct  7 18:51:21 2006
@@ -0,0 +1,277 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.cayenne.DataObject;
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.Fault;
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.ValueHolder;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.util.Util;
+
+/**
+ * DataRowUtils contains a number of static methods to work with DataRows. This is a
+ * helper class for DataContext and ObjectStore.
+ * 
+ * @author Andrus Adamchik
+ * @since 1.1
+ */
+class DataRowUtils {
+
+    /**
+     * Merges changes reflected in snapshot map to the object. Changes made to attributes
+     * and to-one relationships will be merged. In case an object is already modified,
+     * modified properties will not be overwritten.
+     */
+    static void mergeObjectWithSnapshot(
+            DataContext context,
+            ObjEntity entity,
+            DataObject object,
+            DataRow snapshot) {
+
+        int state = object.getPersistenceState();
+
+        if (entity.isReadOnly() || state == PersistenceState.HOLLOW) {
+            refreshObjectWithSnapshot(entity, object, snapshot, true);
+        }
+        else if (state != PersistenceState.COMMITTED) {
+            forceMergeWithSnapshot(context, entity, object, snapshot);
+        }
+        else {
+            // do not invalidate to-many relationships, since they might have
+            // just been prefetched...
+            refreshObjectWithSnapshot(entity, object, snapshot, false);
+        }
+    }
+
+    /**
+     * Replaces all object attribute values with snapshot values. Sets object state to
+     * COMMITTED, unless the snapshot is partial in which case the state is set to HOLLOW
+     */
+    static void refreshObjectWithSnapshot(
+            ObjEntity objEntity,
+            DataObject object,
+            DataRow snapshot,
+            boolean invalidateToManyRelationships) {
+
+        boolean isPartialSnapshot = false;
+
+        Map attrMap = objEntity.getAttributeMap();
+        if (!attrMap.isEmpty()) {
+            Iterator it = attrMap.entrySet().iterator();
+
+            while (it.hasNext()) {
+                Map.Entry entry = (Map.Entry) it.next();
+
+                ObjAttribute attr = (ObjAttribute) entry.getValue();
+                String dbAttrPath = attr.getDbAttributePath();
+
+                Object value = snapshot.get(dbAttrPath);
+                object.writePropertyDirectly(attr.getName(), value);
+
+                // note that a check "snaphsot.get(..) == null" would be incorrect in this
+                // case, as NULL value is entirely valid; still save a map lookup by
+                // checking for the null value first
+                if (value == null && !snapshot.containsKey(dbAttrPath)) {
+                    isPartialSnapshot = true;
+                }
+            }
+        }
+
+        Map rMap = objEntity.getRelationshipMap();
+        if (!rMap.isEmpty()) {
+            Iterator it = rMap.entrySet().iterator();
+            while (it.hasNext()) {
+
+                Map.Entry e = (Map.Entry) it.next();
+                ObjRelationship rel = (ObjRelationship) e.getValue();
+
+                if (rel.isToMany()) {
+
+                    // "to many" relationships have no information to collect from
+                    // snapshot initialize a new empty list if requested, but otherwise
+                    // ignore snapshot data
+
+                    Object toManyList = object.readPropertyDirectly(rel.getName());
+
+                    if (toManyList == null) {
+                        object.writePropertyDirectly(rel.getName(), Fault
+                                .getToManyFault());
+                    }
+                    else if (invalidateToManyRelationships
+                            && toManyList instanceof ValueHolder) {
+                        ((ValueHolder) toManyList).invalidate();
+                    }
+                }
+                else {
+                    // set a shared fault to indicate any kind of unresolved to-one
+                    object.writePropertyDirectly(rel.getName(), Fault.getToOneFault());
+                }
+            }
+        }
+
+        object.setPersistenceState(isPartialSnapshot
+                ? PersistenceState.HOLLOW
+                : PersistenceState.COMMITTED);
+    }
+
+    static void forceMergeWithSnapshot(
+            DataContext context,
+            ObjEntity entity,
+            DataObject object,
+            DataRow snapshot) {
+
+        ObjectDiff diff = (ObjectDiff) context
+                .getObjectStore()
+                .getChangesByObjectId()
+                .get(object.getObjectId());
+
+        // attributes
+        Map attrMap = entity.getAttributeMap();
+        Iterator it = attrMap.entrySet().iterator();
+        while (it.hasNext()) {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            String attrName = (String) entry.getKey();
+            ObjAttribute attr = (ObjAttribute) entry.getValue();
+
+            // processing compound attributes correctly
+            String dbAttrPath = attr.getDbAttributePath();
+
+            // supports merging of partial snapshots...
+            // check for null is cheaper than double lookup
+            // for a key... so check for partial snapshot
+            // only if the value is null
+            Object newVal = snapshot.get(dbAttrPath);
+            if (newVal == null && !snapshot.containsKey(dbAttrPath)) {
+                continue;
+            }
+
+            Object curVal = object.readPropertyDirectly(attrName);
+            Object oldVal = diff != null ? diff.getSnapshotValue(attrName) : null;
+
+            // if value not modified, update it from snapshot,
+            // otherwise leave it alone
+            if (Util.nullSafeEquals(curVal, oldVal)
+                    && !Util.nullSafeEquals(newVal, curVal)) {
+                object.writePropertyDirectly(attrName, newVal);
+            }
+        }
+
+        // merge to-one relationships
+        Iterator rit = entity.getRelationships().iterator();
+        while (rit.hasNext()) {
+            ObjRelationship rel = (ObjRelationship) rit.next();
+
+            // !isToPK check is for handling one-to-one rels pointing to FK... this
+            // feature will require more work in the future
+            if (rel.isToMany() || !rel.isToPK()) {
+                continue;
+            }
+
+            // TODO: will this work for flattened, how do we save snapshots for
+            // them?
+
+            // if value not modified, update it from snapshot,
+            // otherwise leave it alone
+            if (!isToOneTargetModified(rel, object, diff)) {
+
+                DbRelationship dbRelationship = (DbRelationship) rel
+                        .getDbRelationships()
+                        .get(0);
+
+                ObjectId id = snapshot.createTargetObjectId(
+                        rel.getTargetEntityName(),
+                        dbRelationship);
+
+                if (diff == null
+                        || !diff.containsArcSnapshot(rel.getName())
+                        || !Util.nullSafeEquals(id, diff.getArcSnapshotValue(rel
+                                .getName()))) {
+
+                    Object target;
+                    if (id == null) {
+                        target = null;
+                    }
+                    else {
+                        // if inheritance is involved, we can't use 'localObject' .. must
+                        // turn to fault instead
+                        ObjEntity targetEntity = (ObjEntity) rel.getTargetEntity();
+                        if (context.getEntityResolver().lookupInheritanceTree(
+                                targetEntity) != null) {
+                            target = Fault.getToOneFault();
+                        }
+                        else {
+                            target = context.localObject(id, null);
+                        }
+                    }
+
+                    object.writeProperty(rel.getName(), target);
+                }
+            }
+        }
+    }
+
+    /**
+     * Checks if an object has its to-one relationship target modified in memory.
+     */
+    static boolean isToOneTargetModified(
+            ObjRelationship relationship,
+            DataObject object,
+            ObjectDiff diff) {
+
+        if (object.getPersistenceState() != PersistenceState.MODIFIED || diff == null) {
+            return false;
+        }
+
+        Object targetObject = object.readPropertyDirectly(relationship.getName());
+        if (targetObject instanceof Fault) {
+            return false;
+        }
+
+        DataObject toOneTarget = (DataObject) targetObject;
+        ObjectId currentId = (toOneTarget != null) ? toOneTarget.getObjectId() : null;
+
+        // if ObjectId is temporary, target is definitely modified...
+        // this would cover NEW objects (what are the other cases of temp id??)
+        if (currentId != null && currentId.isTemporary()) {
+            return true;
+        }
+
+        if (!diff.containsArcSnapshot(relationship.getName())) {
+            return false;
+        }
+
+        ObjectId targetId = diff.getArcSnapshotValue(relationship.getName());
+        return !Util.nullSafeEquals(currentId, targetId);
+    }
+
+    // not for instantiation
+    DataRowUtils() {
+    }
+}

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java Sat Oct  7 18:51:21 2006
@@ -777,7 +777,7 @@
             }
 
             DataObject dataObj = (DataObject) object;
-            if (dataObj.getDataContext() != dataContext) {
+            if (dataObj.getObjectContext() != dataContext) {
                 return true;
             }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectResolver.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectResolver.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectResolver.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectResolver.java Sat Oct  7 18:51:21 2006
@@ -206,18 +206,22 @@
             case PersistenceState.DELETED:
                 // process the above only if refresh is requested...
                 if (refreshObjects) {
-                    DataRowUtils.mergeObjectWithSnapshot(objectEntity, object, row);
+                    DataRowUtils.mergeObjectWithSnapshot(
+                            context,
+                            objectEntity,
+                            object,
+                            row);
                     object.setSnapshotVersion(row.getVersion());
                 }
                 break;
             case PersistenceState.HOLLOW:
-                if(!refreshObjects) {
+                if (!refreshObjects) {
                     DataRow cachedRow = cache.getCachedSnapshot(anId);
-                    if(cachedRow != null) {
+                    if (cachedRow != null) {
                         row = cachedRow;
                     }
                 }
-                DataRowUtils.mergeObjectWithSnapshot(objectEntity, object, row);
+                DataRowUtils.mergeObjectWithSnapshot(context, objectEntity, object, row);
                 object.setSnapshotVersion(row.getVersion());
                 break;
             default:

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectStore.java Sat Oct  7 18:51:21 2006
@@ -177,15 +177,15 @@
 
                 if (snapshot != null
                         && snapshot.getVersion() != dataObject.getSnapshotVersion()) {
-                    DataContextDelegate delegate = dataObject
-                            .getDataContext()
-                            .nonNullDelegate();
+                    DataContextDelegate delegate = context.nonNullDelegate();
                     if (delegate.shouldMergeChanges(dataObject, snapshot)) {
-                        ObjEntity entity = dataObject
-                                .getDataContext()
-                                .getEntityResolver()
-                                .lookupObjEntity(object);
-                        DataRowUtils.forceMergeWithSnapshot(entity, dataObject, snapshot);
+                        ObjEntity entity = context.getEntityResolver().lookupObjEntity(
+                                object);
+                        DataRowUtils.forceMergeWithSnapshot(
+                                context,
+                                entity,
+                                dataObject,
+                                snapshot);
                         dataObject.setSnapshotVersion(snapshot.getVersion());
                         delegate.finishedMergeChanges(dataObject);
                     }
@@ -300,7 +300,7 @@
      *             {@link RefreshQuery}.
      */
     public synchronized void objectsInvalidated(Collection objects) {
-        if(context != null) {
+        if (context != null) {
             context.invalidateObjects(objects);
         }
     }
@@ -700,18 +700,11 @@
      * 
      * @since 1.1
      */
-    public void resolveHollow(DataObject object) {
+    public void resolveHollow(Persistent object) {
         if (object.getPersistenceState() != PersistenceState.HOLLOW) {
             return;
         }
 
-        // no way to resolve faults outside of DataContext.
-        DataContext context = object.getDataContext();
-        if (context == null) {
-            object.setPersistenceState(PersistenceState.TRANSIENT);
-            return;
-        }
-
         synchronized (this) {
             ObjectIdQuery query = new ObjectIdQuery(
                     object.getObjectId(),
@@ -825,7 +818,7 @@
                         object.setPersistenceState(PersistenceState.HOLLOW);
                         break;
                     case PersistenceState.MODIFIED:
-                        DataContext context = object.getDataContext();
+                        DataContext context = (DataContext) object.getObjectContext();
                         DataRow diff = getSnapshot(oid);
                         // consult delegate if it exists
                         DataContextDelegate delegate = context.nonNullDelegate();
@@ -833,7 +826,11 @@
                             ObjEntity entity = context
                                     .getEntityResolver()
                                     .lookupObjEntity(object);
-                            DataRowUtils.forceMergeWithSnapshot(entity, object, diff);
+                            DataRowUtils.forceMergeWithSnapshot(
+                                    context,
+                                    entity,
+                                    object,
+                                    diff);
                             delegate.finishedMergeChanges(object);
                         }
 
@@ -872,7 +869,7 @@
             // in the future we may want to be more precise and go after modified
             // relationships only, or even process updated lists without invalidating...
 
-            DataContextDelegate delegate = object.getDataContext().nonNullDelegate();
+            DataContextDelegate delegate = context.nonNullDelegate();
 
             if (delegate.shouldMergeChanges(object, null)) {
                 ObjEntity entity = context.getEntityResolver().lookupObjEntity(object);
@@ -947,7 +944,8 @@
                     if (delegate.shouldMergeChanges(object, diff)) {
                         ObjEntity entity = context.getEntityResolver().lookupObjEntity(
                                 object);
-                        DataRowUtils.forceMergeWithSnapshot(entity, object, diff);
+                        DataRowUtils
+                                .forceMergeWithSnapshot(context, entity, object, diff);
                         delegate.finishedMergeChanges(object);
                     }
                 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/ObjectTreeResolver.java Sat Oct  7 18:51:21 2006
@@ -336,7 +336,6 @@
                                 .readProperty(reverseRelationship.getName());
                     }
                     else {
-                        DataContext context = destinationObject.getDataContext();
                         ObjectStore objectStore = context.getObjectStore();
 
                         // prefetched snapshots contain parent ids prefixed with

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectFlattenedRelTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectFlattenedRelTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectFlattenedRelTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectFlattenedRelTst.java Sat Oct  7 18:51:21 2006
@@ -92,7 +92,7 @@
         assertEquals("g1", ((ArtGroup) groupList.get(0)).getName());
 
         // Ensure that the commit doesn't fail
-        a1.getDataContext().commitChanges();
+        a1.getObjectContext().commitChanges();
 
         // and check again
         assertFalse(context.hasChanges());
@@ -126,12 +126,12 @@
         assertEquals("g1", ((ArtGroup) groupList.get(0)).getName());
 
         // Ensure that the commit doesn't fail
-        a1.getDataContext().commitChanges();
+        a1.getObjectContext().commitChanges();
 
         try {
             // The bug caused the second commit to fail (the link record
             // was inserted again)
-            a1.getDataContext().commitChanges();
+            a1.getObjectContext().commitChanges();
         }
         catch (Exception e) {
             e.printStackTrace();
@@ -153,7 +153,7 @@
         assertEquals(0, groupList.size());
 
         // Ensure that the commit doesn't fail
-        a1.getDataContext().commitChanges();
+        a1.getObjectContext().commitChanges();
 
         // and check again
         groupList = a1.getGroupArray();
@@ -167,15 +167,14 @@
         DataContext context = createDataContext();
         createTestData("testRemoveFlattenedRelationshipAndRootRecord");
         Artist a1 = (Artist) DataObjectUtils.objectForPK(context, Artist.class, 33001);
-        DataContext dc = a1.getDataContext();
 
         ArtGroup group = (ArtGroup) a1.getGroupArray().get(0);
         a1.removeFromGroupArray(group); // Cause the delete of the link record
 
-        dc.deleteObject(a1); // Cause the deletion of the artist
+        context.deleteObject(a1); // Cause the deletion of the artist
 
         try {
-            dc.commitChanges();
+            context.commitChanges();
         }
         catch (Exception e) {
             e.printStackTrace();

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectInCtxtTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectInCtxtTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectInCtxtTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectInCtxtTst.java Sat Oct  7 18:51:21 2006
@@ -48,7 +48,7 @@
         ObjectId tempID = object.getObjectId();
         assertNotNull(tempID);
         assertTrue(tempID.isTemporary());
-        assertSame(context, object.getDataContext());
+        assertSame(context, object.getObjectContext());
 
         // double registration in the same context should be quietly ignored
         context.registerNewObject(object);
@@ -182,17 +182,17 @@
         context.commitChanges();
         assertEquals(PersistenceState.TRANSIENT, o1.getPersistenceState());
         assertFalse(context.getGraphManager().registeredNodes().contains(o1));
-        assertNull(o1.getDataContext());
+        assertNull(o1.getObjectContext());
     }
 
     public void testSetDataContext() {
         DataContext context = createDataContext();
 
         Artist o1 = new Artist();
-        assertNull(o1.getDataContext());
+        assertNull(o1.getObjectContext());
 
         context.registerNewObject(o1);
-        assertSame(context, o1.getDataContext());
+        assertSame(context, o1.getObjectContext());
     }
 
     public void testFetchByAttr() throws Exception {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/CayenneDataObjectTst.java Sat Oct  7 18:51:21 2006
@@ -45,6 +45,9 @@
         assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
     }
 
+    /**
+     * @deprecated since 3.0.
+     */
     public void testSetDataContext() throws Exception {
         CayenneDataObject obj = new CayenneDataObject();
         assertNull(obj.getDataContext());

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectSerializationTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectSerializationTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectSerializationTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/DataObjectSerializationTst.java Sat Oct  7 18:51:21 2006
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne;
 
 import java.util.List;
@@ -59,10 +58,8 @@
         assertTrue(deserialized.getObjectId().isTemporary());
         assertEquals("artist1", deserialized.getArtistName());
 
-        assertNull(
-            "CDO serialized by itself shouldn't have a DataContext: "
-                + deserialized.getDataContext(),
-            deserialized.getDataContext());
+        assertNull("CDO serialized by itself shouldn't have a DataContext: "
+                + deserialized.getObjectContext(), deserialized.getObjectContext());
 
         // test that to-many relationships are initialized
         List paintings = deserialized.getPaintingArray();
@@ -82,10 +79,8 @@
         assertTrue(deserialized.getObjectId().isTemporary());
         assertEquals("artist1", deserialized.getArtistName());
 
-        assertNull(
-            "CDO serialized by itself shouldn't have a DataContext: "
-                + deserialized.getDataContext(),
-            deserialized.getDataContext());
+        assertNull("CDO serialized by itself shouldn't have a DataContext: "
+                + deserialized.getObjectContext(), deserialized.getObjectContext());
 
         // test that to-many relationships are initialized
         assertTrue(deserialized.readPropertyDirectly("paintingArray") instanceof ToManyList);
@@ -110,17 +105,16 @@
         // everything must be deserialized, but DataContext link should stay null,
         // and properties shouldn't be populated
         // deserizalized committed object is HOLLOW
-        assertEquals(
-            "Unexpected persistence state: "
-                + PersistenceState.persistenceStateName(deserialized.getPersistenceState()),
-            PersistenceState.HOLLOW,
-            deserialized.getPersistenceState());
+        assertEquals("Unexpected persistence state: "
+                + PersistenceState.persistenceStateName(deserialized
+                        .getPersistenceState()), PersistenceState.HOLLOW, deserialized
+                .getPersistenceState());
 
         assertEquals(id, deserialized.getObjectId());
 
-        // properties of committed objects are not set...when DataContext is 
+        // properties of committed objects are not set...when DataContext is
         // attached to an object, object can populate itself from snapshot
-        assertNull(deserialized.getDataContext());
+        assertNull(deserialized.getObjectContext());
         assertEquals(null, deserialized.getArtistName());
     }
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/MeaningfulFKTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/MeaningfulFKTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/MeaningfulFKTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/MeaningfulFKTst.java Sat Oct  7 18:51:21 2006
@@ -45,12 +45,12 @@
     }
 
     public void testValidateForSave2() throws Exception {
-        MeaningfulFK testObject = (MeaningfulFK) createDataContext()
-                .createAndRegisterNewObject(MeaningfulFK.class);
+        MeaningfulFK testObject = (MeaningfulFK) createDataContext().newObject(
+                MeaningfulFK.class);
 
         RelationshipHelper related = (RelationshipHelper) testObject
-                .getDataContext()
-                .createAndRegisterNewObject(RelationshipHelper.class);
+                .getObjectContext()
+                .newObject(RelationshipHelper.class);
         testObject.setToRelationshipHelper(related);
 
         ValidationResult validation = new ValidationResult();

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/PregeneratedPKTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/PregeneratedPKTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/PregeneratedPKTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/PregeneratedPKTst.java Sat Oct  7 18:51:21 2006
@@ -47,7 +47,7 @@
         Artist a = (Artist) context.createAndRegisterNewObject(Artist.class);
         a.setArtistName("XXX");
 
-        updateId(a);
+        updateId(context, a.getObjectId());
 
         Object pk = a.getObjectId().getReplacementIdMap().get(Artist.ARTIST_ID_PK_COLUMN);
         assertNotNull(pk);
@@ -61,16 +61,14 @@
         assertEquals(pk, pkAfterCommit);
     }
 
-    void updateId(Artist object) throws Exception {
-        DbEntity entity = object.getDataContext().getEntityResolver().lookupDbEntity(
-                object);
-        DataNode node = object.getDataContext().getParentDataDomain().lookupDataNode(
-                entity.getDataMap());
+    void updateId(DataContext context, ObjectId id) throws Exception {
+        DbEntity entity = context.getEntityResolver().lookupDbEntity(Artist.class);
+        DataNode node = context.getParentDataDomain().lookupDataNode(entity.getDataMap());
 
         Object pk = node
                 .getAdapter()
                 .getPkGenerator()
                 .generatePkForDbEntity(node, entity); // throws Exception!!
-        object.getObjectId().getReplacementIdMap().put(Artist.ARTIST_ID_PK_COLUMN, pk);
+        id.getReplacementIdMap().put(Artist.ARTIST_ID_PK_COLUMN, pk);
     }
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateSharedCacheTst.java Sat Oct  7 18:51:21 2006
@@ -36,11 +36,12 @@
 public class DataContextDelegateSharedCacheTst extends MultiContextTestCase {
 
     protected Artist artist;
+    protected DataContext context;
 
     protected void setUp() throws Exception {
         super.setUp();
 
-        DataContext context = createDataContextWithSharedCache();
+        context = createDataContextWithSharedCache();
 
         // prepare a single artist record
         artist = (Artist) context.createAndRegisterNewObject("Artist");
@@ -57,8 +58,6 @@
      */
     public void testShouldMergeChanges() throws Exception {
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         final boolean[] methodInvoked = new boolean[1];
@@ -103,8 +102,6 @@
     public void testBlockedShouldMergeChanges() throws Exception {
         String oldName = artist.getArtistName();
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         DataContextDelegate delegate = new MockDataContextDelegate() {
@@ -139,8 +136,7 @@
      * @throws Exception
      */
     public void testShouldProcessDeleteOnExternalChange() throws Exception {
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
+
         DataContext altContext = mirrorDataContext(context);
 
         final boolean[] methodInvoked = new boolean[1];
@@ -184,8 +180,7 @@
      * @throws Exception
      */
     public void testBlockShouldProcessDeleteOnExternalChange() throws Exception {
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
+
         DataContext altContext = mirrorDataContext(context);
 
         final boolean[] methodInvoked = new boolean[1];
@@ -221,7 +216,7 @@
         };
         helper.assertWithTimeout(3000);
         assertEquals(PersistenceState.COMMITTED, altArtist.getPersistenceState());
-        assertNotNull(altArtist.getDataContext());
+        assertNotNull(altArtist.getObjectContext());
     }
 
     /**
@@ -229,8 +224,6 @@
      * resolution.
      */
     public void testShouldProcessDeleteOnResolveFault() throws Exception {
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
 
         final boolean[] methodInvoked = new boolean[1];
         DataContextDelegate delegate = new MockDataContextDelegate() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextDelegateTst.java Sat Oct  7 18:51:21 2006
@@ -37,13 +37,14 @@
  */
 public class DataContextDelegateTst extends CayenneTestCase {
 
+    protected DataContext context;
     protected Gallery gallery;
     protected Artist artist;
 
     protected void setUp() throws Exception {
         super.setUp();
 
-        DataContext context = createDataContextWithSharedCache();
+        context = createDataContextWithSharedCache();
 
         // prepare a single gallery record
         gallery = (Gallery) context.createAndRegisterNewObject("Gallery");
@@ -57,7 +58,6 @@
     }
 
     public void testWillPerformGenericQuery() throws Exception {
-        DataContext context = gallery.getDataContext();
 
         final List queriesPerformed = new ArrayList(1);
         DataContextDelegate delegate = new MockDataContextDelegate() {
@@ -80,7 +80,6 @@
     }
 
     public void testWillPerformGenericQueryBlocked() throws Exception {
-        DataContext context = gallery.getDataContext();
 
         final List queriesPerformed = new ArrayList(1);
         DataContextDelegate delegate = new MockDataContextDelegate() {
@@ -102,7 +101,6 @@
     }
 
     public void testWillPerformQuery() throws Exception {
-        DataContext context = gallery.getDataContext();
 
         final List queriesPerformed = new ArrayList(1);
         DataContextDelegate delegate = new MockDataContextDelegate() {
@@ -125,7 +123,6 @@
     }
 
     public void testWillPerformQueryBlocked() throws Exception {
-        DataContext context = gallery.getDataContext();
 
         final List queriesPerformed = new ArrayList(1);
         DataContextDelegate delegate = new MockDataContextDelegate() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextObjectTrackingTst.java Sat Oct  7 18:51:21 2006
@@ -52,13 +52,13 @@
         ObjectId oid = obj.getObjectId();
 
         assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
-        assertSame(context, obj.getDataContext());
+        assertSame(context, obj.getObjectContext());
         assertSame(obj, context.getGraphManager().getNode(oid));
 
         context.unregisterObjects(Collections.singletonList(obj));
 
         assertEquals(PersistenceState.TRANSIENT, obj.getPersistenceState());
-        assertNull(obj.getDataContext());
+        assertNull(obj.getObjectContext());
         assertNull(obj.getObjectId());
         assertNull(context.getGraphManager().getNode(oid));
         assertNull(context.getObjectStore().getCachedSnapshot(oid));
@@ -75,13 +75,13 @@
         ObjectId oid = obj.getObjectId();
 
         assertEquals(PersistenceState.COMMITTED, obj.getPersistenceState());
-        assertSame(context, obj.getDataContext());
+        assertSame(context, obj.getObjectContext());
         assertSame(obj, context.getGraphManager().getNode(oid));
 
         context.invalidateObjects(Collections.singletonList(obj));
 
         assertEquals(PersistenceState.HOLLOW, obj.getPersistenceState());
-        assertSame(context, obj.getDataContext());
+        assertSame(context, obj.getObjectContext());
         assertSame(oid, obj.getObjectId());
         assertNull(context.getObjectStore().getCachedSnapshot(oid));
         assertNotNull(context.getGraphManager().getNode(oid));
@@ -162,7 +162,7 @@
             assertEquals(PersistenceState.HOLLOW, committedPeer.getPersistenceState());
             assertEquals(committed.getObjectId(), committedPeer.getObjectId());
             assertSame(peerContext, committedPeer.getObjectContext());
-            assertSame(context, committed.getDataContext());
+            assertSame(context, committed.getObjectContext());
 
             Persistent modifiedPeer = peerContext.localObject(
                     modified.getObjectId(),
@@ -170,13 +170,13 @@
             assertEquals(PersistenceState.HOLLOW, modifiedPeer.getPersistenceState());
             assertEquals(modified.getObjectId(), modifiedPeer.getObjectId());
             assertSame(peerContext, modifiedPeer.getObjectContext());
-            assertSame(context, modified.getDataContext());
+            assertSame(context, modified.getObjectContext());
 
             Persistent deletedPeer = peerContext.localObject(deleted.getObjectId(), null);
             assertEquals(PersistenceState.HOLLOW, deletedPeer.getPersistenceState());
             assertEquals(deleted.getObjectId(), deletedPeer.getObjectId());
             assertSame(peerContext, deletedPeer.getObjectContext());
-            assertSame(context, deleted.getDataContext());
+            assertSame(context, deleted.getObjectContext());
         }
         finally {
             unblockQueries();

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextRefreshingTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextRefreshingTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextRefreshingTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextRefreshingTst.java Sat Oct  7 18:51:21 2006
@@ -248,7 +248,7 @@
         Artist artist = fetchArtist("artist2", false);
         assertNotNull(artist);
 
-        artist.getDataContext().invalidateObjects(Collections.singletonList(artist));
+        context.invalidateObjects(Collections.singletonList(artist));
         assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
 
         // this must trigger a fetch

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSerializationTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSerializationTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSerializationTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSerializationTst.java Sat Oct  7 18:51:21 2006
@@ -139,7 +139,7 @@
         assertEquals(PersistenceState.NEW, deserializedArtist.getPersistenceState());
         assertTrue(deserializedArtist.getObjectId().isTemporary());
         assertEquals("artist1", deserializedArtist.getArtistName());
-        assertSame(deserializedContext, deserializedArtist.getDataContext());
+        assertSame(deserializedContext, deserializedArtist.getObjectContext());
     }
 
     public void testSerializeCommitted() throws Exception {
@@ -169,7 +169,7 @@
         assertEquals(PersistenceState.HOLLOW, deserializedArtist.getPersistenceState());
         assertFalse(deserializedArtist.getObjectId().isTemporary());
         assertEquals("artist1", deserializedArtist.getArtistName());
-        assertSame(deserializedContext, deserializedArtist.getDataContext());
+        assertSame(deserializedContext, deserializedArtist.getObjectContext());
 
         // test that to-many relationships are initialized
         List paintings = deserializedArtist.getPaintingArray();
@@ -205,6 +205,6 @@
         assertEquals(PersistenceState.MODIFIED, deserializedArtist.getPersistenceState());
         assertFalse(deserializedArtist.getObjectId().isTemporary());
         assertEquals("artist2", deserializedArtist.getArtistName());
-        assertSame(deserializedContext, deserializedArtist.getDataContext());
+        assertSame(deserializedContext, deserializedArtist.getObjectContext());
     }
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheEmpiricTst.java Sat Oct  7 18:51:21 2006
@@ -99,7 +99,7 @@
         a1.setArtistName(NEW_NAME);
         assertEquals(NEW_NAME, a1.getArtistName());
         assertEquals(PersistenceState.MODIFIED, a1.getPersistenceState());
-        assertSame(c1, a1.getDataContext());
+        assertSame(c1, a1.getObjectContext());
         assertTrue(c1.hasChanges());
         c1.commitChanges();
 
@@ -145,7 +145,7 @@
         a1.setArtistName(NEW_NAME);
         assertEquals(NEW_NAME, a1.getArtistName());
         assertEquals(PersistenceState.MODIFIED, a1.getPersistenceState());
-        assertSame(c1, a1.getDataContext());
+        assertSame(c1, a1.getObjectContext());
         assertTrue(c1.hasChanges());
         c1.commitChanges();
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataContextSharedCacheTst.java Sat Oct  7 18:51:21 2006
@@ -49,11 +49,12 @@
 public class DataContextSharedCacheTst extends MultiContextTestCase {
 
     protected Artist artist;
+    protected DataContext context;
 
     protected void setUp() throws Exception {
         super.setUp();
 
-        DataContext context = createDataContextWithSharedCache();
+        context = createDataContextWithSharedCache();
 
         // prepare a single artist record
         artist = (Artist) context.createAndRegisterNewObject("Artist");
@@ -65,15 +66,11 @@
     /**
      * Test case to prove that refreshing snapshots as a result of the database fetch will
      * be propagated accross DataContexts.
-     * 
-     * @throws Exception
      */
     public void testSnapshotChangePropagationOnSelect() throws Exception {
         String originalName = artist.getArtistName();
         final String newName = "version2";
 
-        DataContext context = artist.getDataContext();
-
         // create alternative context making sure that no cache is flushed
         DataContext altContext = context.getParentDataDomain().createDataContext(true);
 
@@ -130,8 +127,6 @@
         String originalName = artist.getArtistName();
         final String newName = "version2";
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -181,8 +176,6 @@
         final Date newDate = new Date(originalDate.getTime() - 10000);
         final String newAltName = "version3";
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -231,8 +224,6 @@
      */
     public void testSnapshotDeletePropagationToCommitted() throws Exception {
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -257,7 +248,7 @@
 
             protected void assertResult() throws Exception {
                 assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
-                assertNull(altArtist.getDataContext());
+                assertNull(altArtist.getObjectContext());
             }
         };
         helper.assertWithTimeout(3000);
@@ -272,8 +263,6 @@
      */
     public void testSnapshotDeletePropagationToHollow() throws Exception {
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -297,7 +286,7 @@
 
             protected void assertResult() throws Exception {
                 assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
-                assertNull(altArtist.getDataContext());
+                assertNull(altArtist.getObjectContext());
             }
         };
         helper.assertWithTimeout(3000);
@@ -310,8 +299,6 @@
      */
     public void testSnapshotDeletePropagationToModified() throws Exception {
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -370,8 +357,6 @@
      */
     public void testSnapshotDeletePropagationToDeleted() throws Exception {
 
-        // two contexts being tested
-        DataContext context = artist.getDataContext();
         DataContext altContext = mirrorDataContext(context);
 
         // make sure we have a fully resolved copy of an artist object
@@ -397,7 +382,7 @@
 
             protected void assertResult() throws Exception {
                 assertEquals(PersistenceState.TRANSIENT, altArtist.getPersistenceState());
-                assertNull(altArtist.getDataContext());
+                assertNull(altArtist.getObjectContext());
             }
         };
         helper.assertWithTimeout(3000);
@@ -413,7 +398,6 @@
      * @throws Exception
      */
     public void testSnapshotDeletePropagationToManyRefresh() throws Exception {
-        DataContext context = artist.getDataContext();
 
         Painting painting1 = (Painting) context.createAndRegisterNewObject("Painting");
         painting1.setPaintingTitle("p1");
@@ -485,7 +469,6 @@
      * @throws Exception
      */
     public void testSnapshotInsertPropagationToManyRefresh() throws Exception {
-        DataContext context = artist.getDataContext();
 
         Painting painting1 = (Painting) context.createAndRegisterNewObject("Painting");
         painting1.setPaintingTitle("p1");
@@ -541,8 +524,6 @@
         String originalName = artist.getArtistName();
         final String newName = "version2";
 
-        DataContext context = artist.getDataContext();
-
         DataRow oldSnapshot = context
                 .getObjectStore()
                 .getDataRowCache()
@@ -590,7 +571,7 @@
         String originalName = artist.getArtistName();
         final String newName = "version2";
 
-        DataContext context = artist.getDataContext();
+        DataContext context = (DataContext) artist.getObjectContext();
 
         DataRow oldSnapshot = context
                 .getObjectStore()
@@ -632,7 +613,6 @@
 
     public void testSnapshotEvictedForHollow() throws Exception {
         String originalName = artist.getArtistName();
-        DataContext context = artist.getDataContext();
 
         context.invalidateObjects(Collections.singletonList(artist));
         assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
@@ -651,7 +631,6 @@
 
     public void testSnapshotEvictedAndObjectsHollowedForInvalidate() throws Exception {
         String originalName = artist.getArtistName();
-        DataContext context = artist.getDataContext();
 
         // create alternative context
         DataContext altContext = mirrorDataContext(context);
@@ -690,7 +669,6 @@
 
     public void testSnapshotEvictedForCommitted() throws Exception {
         String newName = "version2";
-        DataContext context = artist.getDataContext();
 
         assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
 
@@ -713,7 +691,6 @@
 
     public void testSnapshotEvictedForModified() throws Exception {
         String newName = "version2";
-        DataContext context = artist.getDataContext();
 
         assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
 
@@ -739,7 +716,6 @@
         String originalName = artist.getArtistName();
         String newName = "version2";
         String backendName = "version3";
-        DataContext context = artist.getDataContext();
 
         assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
 
@@ -774,8 +750,6 @@
     public void testSnapshotEvictedForDeleted() throws Exception {
         // remember ObjectId
         ObjectId id = artist.getObjectId();
-
-        DataContext context = artist.getDataContext();
 
         assertEquals(PersistenceState.COMMITTED, artist.getPersistenceState());
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataRowUtilsTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataRowUtilsTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataRowUtilsTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/DataRowUtilsTst.java Sat Oct  7 18:51:21 2006
@@ -60,7 +60,7 @@
         s2.put("ARTIST_NAME", n2);
         s2.put("DATE_OF_BIRTH", new java.util.Date());
         ObjEntity e = context.getEntityResolver().lookupObjEntity(a1);
-        DataRowUtils.mergeObjectWithSnapshot(e, a1, s2);
+        DataRowUtils.mergeObjectWithSnapshot(context, e, a1, s2);
 
         // name was modified, so it should not change during merge
         assertEquals(n1, a1.getArtistName());

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/IdentityColumnsTst.java Sat Oct  7 18:51:21 2006
@@ -51,7 +51,7 @@
         String name = "n_" + System.currentTimeMillis();
         idObject.setName(name);
 
-        idObject.getDataContext().commitChanges();
+        idObject.getObjectContext().commitChanges();
 
         // this will throw an exception if id wasn't generated one way or another
         int id = DataObjectUtils.intPKForObject(idObject);
@@ -239,8 +239,10 @@
                 master2, dependent
         }));
 
-        assertNotNull(DataObjectUtils
-                .objectForPK(context, GeneratedColumnTestEntity.class, id1));
+        assertNotNull(DataObjectUtils.objectForPK(
+                context,
+                GeneratedColumnTestEntity.class,
+                id1));
         assertNotNull(DataObjectUtils.objectForPK(context, GeneratedColumnDep.class, id2));
     }
 
@@ -257,8 +259,8 @@
         idObject.setName("aaa");
 
         GeneratedColumnDep dependent = (GeneratedColumnDep) idObject
-                .getDataContext()
-                .createAndRegisterNewObject(GeneratedColumnDep.class);
+                .getObjectContext()
+                .newObject(GeneratedColumnDep.class);
         dependent.setName("aaa");
         dependent.setToMaster(idObject);
 
@@ -278,8 +280,10 @@
                 idObject, dependent
         }));
 
-        assertNotNull(DataObjectUtils
-                .objectForPK(context, GeneratedColumnTestEntity.class, id1));
+        assertNotNull(DataObjectUtils.objectForPK(
+                context,
+                GeneratedColumnTestEntity.class,
+                id1));
         assertNotNull(DataObjectUtils.objectForPK(context, GeneratedColumnDep.class, id2));
     }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/NestedDataContextReadTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/NestedDataContextReadTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/NestedDataContextReadTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/NestedDataContextReadTst.java Sat Oct  7 18:51:21 2006
@@ -115,7 +115,7 @@
             assertEquals(PersistenceState.COMMITTED, newPeer.getPersistenceState());
 
             assertSame(childContext, newPeer.getObjectContext());
-            assertSame(context, _new.getDataContext());
+            assertSame(context, _new.getObjectContext());
 
             Persistent hollowPeer = childContext
                     .localObject(hollow.getObjectId(), hollow);
@@ -130,15 +130,15 @@
             assertEquals(PersistenceState.COMMITTED, committedPeer.getPersistenceState());
             assertEquals(committed.getObjectId(), committedPeer.getObjectId());
             assertSame(childContext, committedPeer.getObjectContext());
-            assertSame(context, committed.getDataContext());
+            assertSame(context, committed.getObjectContext());
 
             Artist modifiedPeer = (Artist) childContext.localObject(modified
                     .getObjectId(), modified);
             assertEquals(PersistenceState.COMMITTED, modifiedPeer.getPersistenceState());
             assertEquals(modified.getObjectId(), modifiedPeer.getObjectId());
             assertEquals("M1", modifiedPeer.getArtistName());
-            assertSame(childContext, modifiedPeer.getDataContext());
-            assertSame(context, modified.getDataContext());
+            assertSame(childContext, modifiedPeer.getObjectContext());
+            assertSame(context, modified.getObjectContext());
 
             Persistent deletedPeer = childContext.localObject(
                     deleted.getObjectId(),
@@ -146,7 +146,7 @@
             assertEquals(PersistenceState.COMMITTED, deletedPeer.getPersistenceState());
             assertEquals(deleted.getObjectId(), deletedPeer.getObjectId());
             assertSame(childContext, deletedPeer.getObjectContext());
-            assertSame(context, deleted.getDataContext());
+            assertSame(context, deleted.getObjectContext());
         }
         finally {
             unblockQueries();

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectStoreDiffRetainingTst.java Sat Oct  7 18:51:21 2006
@@ -37,11 +37,9 @@
     public void testSnapshotRetainedOnPropertyModification() throws Exception {
         createTestData("test");
 
-        Artist a = (Artist) DataObjectUtils.objectForPK(
-                createDataContext(),
-                Artist.class,
-                2000);
-        ObjectStore objectStore = a.getDataContext().getObjectStore();
+        DataContext context = createDataContext();
+        Artist a = (Artist) DataObjectUtils.objectForPK(context, Artist.class, 2000);
+        ObjectStore objectStore = context.getObjectStore();
 
         assertNull(objectStore.getChangesByObjectId().get(a.getObjectId()));
 
@@ -52,11 +50,9 @@
     public void testSnapshotRetainedOnRelAndPropertyModification() throws Exception {
         createTestData("test");
 
-        Artist a = (Artist) DataObjectUtils.objectForPK(
-                createDataContext(),
-                Artist.class,
-                2000);
-        ObjectStore objectStore = a.getDataContext().getObjectStore();
+        DataContext context = createDataContext();
+        Artist a = (Artist) DataObjectUtils.objectForPK(context, Artist.class, 2000);
+        ObjectStore objectStore = context.getObjectStore();
 
         assertNull(objectStore.getChangesByObjectId().get(a.getObjectId()));
 
@@ -65,8 +61,7 @@
         // snapshot is not retained... in testing this I am leaving some flexibility for
         // the framework to retain a snapshot when it deems appropriate...
 
-        a.addToPaintingArray((Painting) a.getDataContext().createAndRegisterNewObject(
-                Painting.class));
+        a.addToPaintingArray((Painting) context.newObject(Painting.class));
         a.setArtistName("some other name");
         assertNotNull("Snapshot wasn't retained - CAY-213", objectStore
                 .getChangesByObjectId()

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/TransactionThreadTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/TransactionThreadTst.java?view=diff&rev=454062&r1=454061&r2=454062
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/TransactionThreadTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/TransactionThreadTst.java Sat Oct  7 18:51:21 2006
@@ -75,7 +75,7 @@
         getDomain().setTransactionDelegate(delegate);
 
         try {
-            a.getDataContext().commitChanges();
+            a.getObjectContext().commitChanges();
         }
         finally {
             getDomain().setTransactionDelegate(null);



Mime
View raw message