cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r463113 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/map/ main/java/org/apache/cayenne/property/ main/java/org/apache/cayenne/query/ main/java/org/apache/cayen...
Date Thu, 12 Oct 2006 02:47:39 GMT
Author: aadamchik
Date: Wed Oct 11 19:47:29 2006
New Revision: 463113

URL: http://svn.apache.org/viewvc?view=rev&rev=463113
Log:
This affects two issues:

CAY-687: New method: QueryMetadata.getClassDescriptor() 
(added)
CAY-686:Weed out DataObject references from the access stack classes, replacing them with Persistent and ClassDescriptor
(partially switching select pipeline to Persistent object.)

Added:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AttributeProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java
Modified:
    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/DataDomainQuery.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.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/main/java/org/apache/cayenne/map/EntityDescriptor.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ArcProperty.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/Property.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadata.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/RangeQuery.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/FlattenedRelationshipInContextTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectTreeResolver_TreeBuilderTst.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java

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=463113&r1=463112&r2=463113
==============================================================================
--- 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 Wed Oct 11 19:47:29 2006
@@ -544,18 +544,20 @@
      * @since 1.1
      */
     public DataRow currentSnapshot(Persistent object) {
-      
+
         // for a HOLLOW object return snapshot from cache
         if (object.getPersistenceState() == PersistenceState.HOLLOW
                 && object.getObjectContext() != null) {
 
             return getObjectStore().getSnapshot(object.getObjectId());
         }
-        
-        // TODO: andrus, 10/10/2006 - use descriptor visitor instead of entity attribute iterator
-        
+
+        // TODO: andrus, 10/10/2006 - use descriptor visitor instead of entity attribute
+        // iterator
+
         ObjEntity entity = getEntityResolver().lookupObjEntity(object);
-        ClassDescriptor descriptor = getEntityResolver().getClassDescriptor(entity.getName());
+        ClassDescriptor descriptor = getEntityResolver().getClassDescriptor(
+                entity.getName());
         DataRow snapshot = new DataRow(10);
 
         Iterator attributes = entity.getAttributeMap().entrySet().iterator();
@@ -658,7 +660,12 @@
             boolean refresh,
             boolean resolveInheritanceHierarchy) {
 
-        return new ObjectResolver(this, entity, refresh, resolveInheritanceHierarchy)
+        // TODO: andrus, 10/11/2006 - instead of doing ClassDescriptor lookup, deprecate
+        // this method, replacing it with the one that takes CD as argument. Or get rid of
+        // it all together
+        ClassDescriptor descriptor = getEntityResolver().getClassDescriptor(
+                entity.getName());
+        return new ObjectResolver(this, descriptor, refresh, resolveInheritanceHierarchy)
                 .synchronizedObjectsFromDataRows(dataRows);
     }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQuery.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQuery.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQuery.java Wed Oct 11 19:47:29 2006
@@ -23,6 +23,7 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryMetadata;
@@ -83,6 +84,10 @@
     }
 
     public ObjEntity getObjEntity() {
+        return null;
+    }
+    
+    public ClassDescriptor getClassDescriptor() {
         return null;
     }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java Wed Oct 11 19:47:29 2006
@@ -40,6 +40,7 @@
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchSelectQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
@@ -123,7 +124,7 @@
 
         return response;
     }
-    
+
     private boolean interceptDataDomainQuery() {
         if (query instanceof DataDomainQuery) {
             response = new ListResponse(domain);
@@ -351,7 +352,7 @@
 
         return DONE;
     }
-    
+
     private QueryCacheEntryFactory getCacheObjectFactory() {
         return new QueryCacheEntryFactory() {
 
@@ -424,12 +425,12 @@
             if (mainRows != null && !mainRows.isEmpty()) {
 
                 List objects;
-                ObjEntity entity = metadata.getObjEntity();
+                ClassDescriptor descriptor = metadata.getClassDescriptor();
                 PrefetchTreeNode prefetchTree = metadata.getPrefetchTree();
 
                 // take a shortcut when no prefetches exist...
                 if (prefetchTree == null) {
-                    objects = new ObjectResolver(context, entity, metadata
+                    objects = new ObjectResolver(context, descriptor, metadata
                             .isRefreshingObjects(), metadata.isResolvingInherited())
                             .synchronizedObjectsFromDataRows(mainRows);
                 }

Modified: 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=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/access/DataRowUtils.java Wed Oct 11 19:47:29 2006
@@ -19,19 +19,23 @@
 
 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.Persistent;
 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.property.AttributeProperty;
+import org.apache.cayenne.property.ClassDescriptor;
+import org.apache.cayenne.property.CollectionProperty;
+import org.apache.cayenne.property.Property;
+import org.apache.cayenne.property.PropertyVisitor;
+import org.apache.cayenne.property.SingleObjectArcProperty;
 import org.apache.cayenne.util.Util;
 
 /**
@@ -50,22 +54,22 @@
      */
     static void mergeObjectWithSnapshot(
             DataContext context,
-            ObjEntity entity,
+            ClassDescriptor descriptor,
             DataObject object,
             DataRow snapshot) {
 
         int state = object.getPersistenceState();
 
-        if (entity.isReadOnly() || state == PersistenceState.HOLLOW) {
-            refreshObjectWithSnapshot(entity, object, snapshot, true);
+        if (state == PersistenceState.HOLLOW || descriptor.getEntity().isReadOnly()) {
+            refreshObjectWithSnapshot(descriptor, object, snapshot, true);
         }
         else if (state != PersistenceState.COMMITTED) {
-            forceMergeWithSnapshot(context, entity, object, snapshot);
+            forceMergeWithSnapshot(context, descriptor, object, snapshot);
         }
         else {
             // do not invalidate to-many relationships, since they might have
             // just been prefetched...
-            refreshObjectWithSnapshot(entity, object, snapshot, false);
+            refreshObjectWithSnapshot(descriptor, object, snapshot, false);
         }
     }
 
@@ -74,182 +78,167 @@
      * 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;
+            ClassDescriptor descriptor,
+            final Persistent object,
+            final DataRow snapshot,
+            final boolean invalidateToManyRelationships) {
 
-        Map attrMap = objEntity.getAttributeMap();
-        if (!attrMap.isEmpty()) {
-            Iterator it = attrMap.entrySet().iterator();
+        final boolean[] isPartialSnapshot = new boolean[1];
 
-            while (it.hasNext()) {
-                Map.Entry entry = (Map.Entry) it.next();
+        descriptor.visitProperties(new PropertyVisitor() {
 
-                ObjAttribute attr = (ObjAttribute) entry.getValue();
+            public boolean visitProperty(Property property) {
+                ObjAttribute attr = ((AttributeProperty) property).getAttribute();
                 String dbAttrPath = attr.getDbAttributePath();
 
                 Object value = snapshot.get(dbAttrPath);
-                object.writePropertyDirectly(attr.getName(), value);
+                property.writePropertyDirectly(object, null, 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;
+                    isPartialSnapshot[0] = true;
                 }
+                return 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();
+            public boolean visitCollectionArc(CollectionProperty property) {
+                // "to many" relationships have no information to collect from
+                // snapshot initialize a new empty list if requested, but otherwise
+                // ignore snapshot data
 
-                if (rel.isToMany()) {
+                Object toManyList = property.readPropertyDirectly(object);
 
-                    // "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();
-                    }
+                if (toManyList == null) {
+                    property.writePropertyDirectly(object, null, Fault.getToManyFault());
                 }
-                else {
-                    // set a shared fault to indicate any kind of unresolved to-one
-                    object.writePropertyDirectly(rel.getName(), Fault.getToOneFault());
+                else if (invalidateToManyRelationships
+                        && toManyList instanceof ValueHolder) {
+                    ((ValueHolder) toManyList).invalidate();
                 }
+
+                return true;
             }
-        }
 
-        object.setPersistenceState(isPartialSnapshot
+            public boolean visitSingleObjectArc(SingleObjectArcProperty property) {
+                property.writePropertyDirectly(object, null, Fault.getToOneFault());
+                return true;
+            }
+        });
+
+        object.setPersistenceState(isPartialSnapshot[0]
                 ? PersistenceState.HOLLOW
                 : PersistenceState.COMMITTED);
     }
 
     static void forceMergeWithSnapshot(
-            DataContext context,
-            ObjEntity entity,
-            DataObject object,
-            DataRow snapshot) {
+            final DataContext context,
+            ClassDescriptor descriptor,
+            final Persistent object,
+            final DataRow snapshot) {
 
-        ObjectDiff diff = (ObjectDiff) context
+        final 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();
+        descriptor.visitProperties(new PropertyVisitor() {
 
-            // 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;
+            public boolean visitProperty(Property property) {
+                String dbAttrPath = ((AttributeProperty) property)
+                        .getAttribute()
+                        .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 newValue = snapshot.get(dbAttrPath);
+                if (newValue != null || snapshot.containsKey(dbAttrPath)) {
+
+                    Object curValue = property.readPropertyDirectly(object);
+                    Object oldValue = diff != null ? diff.getSnapshotValue(property
+                            .getName()) : null;
+
+                    // if value not modified, update it from snapshot,
+                    // otherwise leave it alone
+                    if (Util.nullSafeEquals(curValue, oldValue)
+                            && !Util.nullSafeEquals(newValue, curValue)) {
+                        property.writePropertyDirectly(object, oldValue, newValue);
+                    }
+                }
+                return true;
             }
 
-            // TODO: will this work for flattened, how do we save snapshots for
-            // them?
+            public boolean visitCollectionArc(CollectionProperty property) {
+                // noop - nothing to merge
+                return true;
+            }
+
+            public boolean visitSingleObjectArc(SingleObjectArcProperty property) {
+                ObjRelationship relationship = property.getRelationship();
+                if (relationship.isToPK()) {
+                    // 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(property, object, diff)) {
+
+                        DbRelationship dbRelationship = (DbRelationship) relationship
+                                .getDbRelationships()
+                                .get(0);
+
+                        ObjectId id = snapshot.createTargetObjectId(relationship
+                                .getTargetEntityName(), dbRelationship);
+
+                        if (diff == null
+                                || !diff.containsArcSnapshot(relationship.getName())
+                                || !Util.nullSafeEquals(id, diff
+                                        .getArcSnapshotValue(relationship.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) relationship
+                                        .getTargetEntity();
+                                if (context.getEntityResolver().lookupInheritanceTree(
+                                        targetEntity) != null) {
+                                    target = Fault.getToOneFault();
+                                }
+                                else {
+                                    target = context.localObject(id, null);
+                                }
+                            }
 
-            // 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);
+                            property.writeProperty(object, null, target);
                         }
                     }
-
-                    object.writeProperty(rel.getName(), target);
                 }
+                return true;
             }
-        }
+        });
     }
 
     /**
      * Checks if an object has its to-one relationship target modified in memory.
      */
     static boolean isToOneTargetModified(
-            ObjRelationship relationship,
-            DataObject object,
+            Property property,
+            Persistent object,
             ObjectDiff diff) {
 
         if (object.getPersistenceState() != PersistenceState.MODIFIED || diff == null) {
             return false;
         }
 
-        Object targetObject = object.readPropertyDirectly(relationship.getName());
+        Object targetObject = property.readPropertyDirectly(object);
         if (targetObject instanceof Fault) {
             return false;
         }
@@ -263,11 +252,11 @@
             return true;
         }
 
-        if (!diff.containsArcSnapshot(relationship.getName())) {
+        if (!diff.containsArcSnapshot(property.getName())) {
             return false;
         }
 
-        ObjectId targetId = diff.getArcSnapshotValue(relationship.getName());
+        ObjectId targetId = diff.getArcSnapshotValue(property.getName());
         return !Util.nullSafeEquals(currentId, targetId);
     }
 

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=463113&r1=463112&r2=463113
==============================================================================
--- 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 Wed Oct 11 19:47:29 2006
@@ -30,10 +30,12 @@
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.Persistent;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityInheritanceTree;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.property.ClassDescriptor;
 
 /**
  * DataRows-to-objects converter for a specific ObjEntity.
@@ -44,7 +46,7 @@
 class ObjectResolver {
 
     DataContext context;
-    ObjEntity entity;
+    ClassDescriptor descriptor;
     List primaryKey;
 
     EntityInheritanceTree inheritanceTree;
@@ -52,28 +54,28 @@
     boolean resolveInheritance;
     DataRowStore cache;
 
-    ObjectResolver(DataContext context, ObjEntity entity, boolean refresh,
+    ObjectResolver(DataContext context, ClassDescriptor descriptor, boolean refresh,
             boolean resolveInheritanceHierarchy) {
-        init(context, entity, refresh, resolveInheritanceHierarchy);
+        init(context, descriptor, refresh, resolveInheritanceHierarchy);
     }
 
     void init(
             DataContext context,
-            ObjEntity entity,
+            ClassDescriptor descriptor,
             boolean refresh,
             boolean resolveInheritanceHierarchy) {
         // sanity check
-        DbEntity dbEntity = entity.getDbEntity();
+        DbEntity dbEntity = descriptor.getEntity().getDbEntity();
         if (dbEntity == null) {
             throw new CayenneRuntimeException("ObjEntity '"
-                    + entity.getName()
+                    + descriptor.getEntity().getName()
                     + "' has no DbEntity.");
         }
 
         this.primaryKey = dbEntity.getPrimaryKey();
         if (primaryKey.size() == 0) {
             throw new CayenneRuntimeException("Won't be able to create ObjectId for '"
-                    + entity.getName()
+                    + descriptor.getEntity().getName()
                     + "'. Reason: DbEntity '"
                     + dbEntity.getName()
                     + "' has no Primary Key defined.");
@@ -82,8 +84,9 @@
         this.context = context;
         this.cache = context.getObjectStore().getDataRowCache();
         this.refreshObjects = refresh;
-        this.entity = entity;
-        this.inheritanceTree = context.getEntityResolver().lookupInheritanceTree(entity);
+        this.descriptor = descriptor;
+        this.inheritanceTree = context.getEntityResolver().lookupInheritanceTree(
+                descriptor.getEntity());
         this.resolveInheritance = (inheritanceTree != null)
                 ? resolveInheritanceHierarchy
                 : false;
@@ -147,7 +150,7 @@
         while (it.hasNext()) {
 
             DataRow row = (DataRow) it.next();
-            DataObject object = objectFromDataRow(row);
+            DataObject object = (DataObject) objectFromDataRow(row);
             results.add(object);
 
             // link with parent
@@ -174,26 +177,26 @@
      * Processes a single row. This method does not synchronize on ObjectStore and doesn't
      * send snapshot updates. These are responsibilities of the caller.
      */
-    DataObject objectFromDataRow(DataRow row) {
+    Persistent objectFromDataRow(DataRow row) {
 
         // determine entity to use
-        ObjEntity objectEntity;
+        ClassDescriptor classDescriptor;
 
         if (resolveInheritance) {
-            objectEntity = inheritanceTree.entityMatchingRow(row);
+            ObjEntity objectEntity = inheritanceTree.entityMatchingRow(row);
 
-            // still null.... looks like inheritance qualifiers are messed up
-            if (objectEntity == null) {
-                objectEntity = entity;
-            }
+            // null probably means that inheritance qualifiers are messed up
+            classDescriptor = (objectEntity != null) ? context
+                    .getEntityResolver()
+                    .getClassDescriptor(objectEntity.getName()) : descriptor;
         }
         else {
-            objectEntity = entity;
+            classDescriptor = descriptor;
         }
 
         // not using DataRow.createObjectId for performance reasons - ObjectResolver has
         // all needed metadata already cached.
-        ObjectId anId = createObjectId(row, objectEntity, null);
+        ObjectId anId = createObjectId(row, classDescriptor.getEntity(), null);
 
         // this will create a HOLLOW object if it is not registered yet
         DataObject object = (DataObject) context.localObject(anId, null);
@@ -208,7 +211,7 @@
                 if (refreshObjects) {
                     DataRowUtils.mergeObjectWithSnapshot(
                             context,
-                            objectEntity,
+                            classDescriptor,
                             object,
                             row);
                     object.setSnapshotVersion(row.getVersion());
@@ -221,7 +224,11 @@
                         row = cachedRow;
                     }
                 }
-                DataRowUtils.mergeObjectWithSnapshot(context, objectEntity, object, row);
+                DataRowUtils.mergeObjectWithSnapshot(
+                        context,
+                        classDescriptor,
+                        object,
+                        row);
                 object.setSnapshotVersion(row.getVersion());
                 break;
             default:
@@ -232,12 +239,16 @@
     }
 
     ObjEntity getEntity() {
-        return entity;
+        return descriptor.getEntity();
+    }
+    
+    ClassDescriptor getDescriptor() {
+        return descriptor;
     }
 
     ObjectId createObjectId(DataRow dataRow, ObjEntity objEntity, String namePrefix) {
 
-        List pk = objEntity == this.entity ? this.primaryKey : objEntity
+        List pk = objEntity == this.descriptor.getEntity() ? this.primaryKey : objEntity
                 .getDbEntity()
                 .getPrimaryKey();
 

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=463113&r1=463112&r2=463113
==============================================================================
--- 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 Wed Oct 11 19:47:29 2006
@@ -49,6 +49,7 @@
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.QueryMetadata;
@@ -133,12 +134,13 @@
                             && snapshot.getVersion() != dataObject.getSnapshotVersion()) {
                         DataContextDelegate delegate = context.nonNullDelegate();
                         if (delegate.shouldMergeChanges(dataObject, snapshot)) {
-                            ObjEntity entity = context
+                            ClassDescriptor descriptor = context
                                     .getEntityResolver()
-                                    .lookupObjEntity(object);
+                                    .getClassDescriptor(
+                                            ((ObjectId) nodeId).getEntityName());
                             DataRowUtils.forceMergeWithSnapshot(
                                     context,
-                                    entity,
+                                    descriptor,
                                     dataObject,
                                     snapshot);
                             dataObject.setSnapshotVersion(snapshot.getVersion());
@@ -772,12 +774,12 @@
                         // consult delegate if it exists
                         DataContextDelegate delegate = context.nonNullDelegate();
                         if (delegate.shouldMergeChanges(object, diff)) {
-                            ObjEntity entity = context
+                            ClassDescriptor descriptor = context
                                     .getEntityResolver()
-                                    .lookupObjEntity(object);
+                                    .getClassDescriptor(oid.getEntityName());
                             DataRowUtils.forceMergeWithSnapshot(
                                     context,
-                                    entity,
+                                    descriptor,
                                     object,
                                     diff);
                             delegate.finishedMergeChanges(object);
@@ -862,8 +864,9 @@
                     // consult delegate if it exists
                     DataContextDelegate delegate = context.nonNullDelegate();
                     if (delegate.shouldMergeChanges(object, diff)) {
-                        ObjEntity entity = context.getEntityResolver().lookupObjEntity(
-                                object);
+                        ClassDescriptor descriptor = context
+                                .getEntityResolver()
+                                .getClassDescriptor(((ObjectId) nodeId).getEntityName());
 
                         // TODO: andrus, 5/26/2006 - call to 'getSnapshot' is expensive,
                         // however my attempts to merge the 'diff' instead of snapshot
@@ -877,7 +880,7 @@
                         DataRow snapshot = getSnapshot(object.getObjectId());
 
                         DataRowUtils.refreshObjectWithSnapshot(
-                                entity,
+                                descriptor,
                                 object,
                                 snapshot,
                                 true);
@@ -891,10 +894,14 @@
                     // consult delegate if it exists
                     DataContextDelegate delegate = context.nonNullDelegate();
                     if (delegate.shouldMergeChanges(object, diff)) {
-                        ObjEntity entity = context.getEntityResolver().lookupObjEntity(
-                                object);
-                        DataRowUtils
-                                .forceMergeWithSnapshot(context, entity, object, diff);
+                        ClassDescriptor descriptor = context
+                                .getEntityResolver()
+                                .getClassDescriptor(((ObjectId) nodeId).getEntityName());
+                        DataRowUtils.forceMergeWithSnapshot(
+                                context,
+                                descriptor,
+                                object,
+                                diff);
                         delegate.finishedMergeChanges(object);
                     }
                 }
@@ -1101,6 +1108,10 @@
         }
 
         public ObjEntity getObjEntity() {
+            return null;
+        }
+        
+        public ClassDescriptor getClassDescriptor() {
             return null;
         }
 

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=463113&r1=463112&r2=463113
==============================================================================
--- 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 Wed Oct 11 19:47:29 2006
@@ -32,6 +32,8 @@
 import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.ArcProperty;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.PrefetchProcessor;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.QueryMetadata;
@@ -190,37 +192,37 @@
         boolean addNode(PrefetchProcessorNode node) {
 
             List rows;
-            ObjRelationship relationship;
-            ObjEntity entity;
+            ArcProperty arc;
+            ClassDescriptor descriptor;
 
             PrefetchProcessorNode currentNode = getParent();
 
             if (currentNode != null) {
                 rows = (List) extraResultsByPath.get(node.getPath());
-                relationship = (ObjRelationship) currentNode
+                arc = (ArcProperty) currentNode
                         .getResolver()
-                        .getEntity()
-                        .getRelationship(node.getName());
+                        .getDescriptor()
+                        .getProperty(node.getName());
 
-                if (relationship == null) {
+                if (arc == null) {
                     throw new CayenneRuntimeException("No relationship with name '"
                             + node.getName()
                             + "' found in entity "
                             + currentNode.getResolver().getEntity().getName());
                 }
 
-                entity = (ObjEntity) relationship.getTargetEntity();
+                descriptor = arc.getTargetDescriptor();
             }
             else {
-                relationship = null;
-                entity = queryMetadata.getObjEntity();
+                arc = null;
+                descriptor = queryMetadata.getClassDescriptor();
                 rows = mainResultRows;
             }
 
             node.setDataRows(rows);
-            node.setResolver(new ObjectResolver(context, entity, queryMetadata
+            node.setResolver(new ObjectResolver(context, descriptor, queryMetadata
                     .isRefreshingObjects(), queryMetadata.isResolvingInherited()));
-            node.setIncoming(relationship);
+            node.setIncoming(arc != null ? arc.getRelationship() : null);
 
             if (currentNode != null) {
                 currentNode.addChild(node);
@@ -414,7 +416,7 @@
             if (object == null) {
 
                 DataRow row = processorNode.rowFromFlatRow(currentFlatRow);
-                object = processorNode.getResolver().objectFromDataRow(row);
+                object = (DataObject) processorNode.getResolver().objectFromDataRow(row);
 
                 processorNode.putResolved(id, object);
                 processorNode.addObject(object, row);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/map/EntityDescriptor.java Wed Oct 11 19:47:29 2006
@@ -24,9 +24,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.cayenne.DataObject;
-import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.ValueHolder;
 import org.apache.cayenne.property.BaseClassDescriptor;
@@ -39,9 +37,11 @@
 import org.apache.cayenne.property.Property;
 import org.apache.cayenne.property.PropertyAccessException;
 import org.apache.cayenne.property.PropertyAccessor;
+import org.apache.cayenne.property.SimplePersistentProperty;
 import org.apache.cayenne.property.SimpleProperty;
 import org.apache.cayenne.property.ToManyListProperty;
 import org.apache.cayenne.property.ValueHolderProperty;
+import org.apache.commons.lang.builder.ToStringBuilder;
 
 /**
  * A ClassDescriptor describing a persistent bean based on ObjEntity.
@@ -122,7 +122,7 @@
 
         // before we compile attributes, extract all relationship descriptors to a
         // separate value holder map
-        if(!allDescriptors.isEmpty()) {
+        if (!allDescriptors.isEmpty()) {
             this.valueHolderProperties = new HashMap(allDescriptors);
         }
 
@@ -180,7 +180,7 @@
             Class propertyType = attribute.getJavaClass();
             PropertyAccessor accessor = makeAccessor(attribute.getName(), propertyType);
             allDescriptors.put(attribute.getName(), persistent
-                    ? new SimplePersistentProperty(this, accessor)
+                    ? new SimplePersistentProperty(this, accessor, attribute)
                     : new SimpleProperty(this, accessor));
         }
     }
@@ -286,40 +286,5 @@
         return new ToStringBuilder(this).append("entity", entityName).append(
                 "objectClass",
                 className).toString();
-    }
-
-    // TODO: andrus, 4/26/2006 - this property was added when 1.2 was in public API freeze
-    // - move it to the property package past 1.2
-    final class SimplePersistentProperty extends SimpleProperty {
-
-        SimplePersistentProperty(ClassDescriptor owner, PropertyAccessor accessor) {
-            super(owner, accessor);
-        }
-
-        public Object readProperty(Object object) throws PropertyAccessException {
-            resolveFault(object);
-            return super.readProperty(object);
-        }
-
-        public void writeProperty(Object object, Object oldValue, Object newValue)
-                throws PropertyAccessException {
-            resolveFault(object);
-            super.writeProperty(object, oldValue, newValue);
-        }
-
-        void resolveFault(Object object) throws PropertyAccessException {
-            try {
-                Persistent persistent = (Persistent) object;
-                ObjectContext context = persistent.getObjectContext();
-                if (context != null) {
-                    context.prepareForAccess(persistent, getName());
-                }
-            }
-            catch (ClassCastException e) {
-                throw new PropertyAccessException("Object is not a Persistent: '"
-                        + object.getClass().getName()
-                        + "'", this, object, e);
-            }
-        }
     }
 }

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractCollectionProperty.java Wed Oct 11 19:47:29 2006
@@ -49,9 +49,14 @@
     public void writePropertyDirectly(Object object, Object oldValue, Object newValue)
             throws PropertyAccessException {
 
-        // must resolve value holder...
-        ValueHolder holder = (ValueHolder) readProperty(object);
-        holder.setValueDirectly(newValue);
+        if (newValue instanceof Fault) {
+            super.writePropertyDirectly(object, null, newValue);
+        }
+        else {
+            // must resolve value holder...
+            ValueHolder holder = (ValueHolder) readProperty(object);
+            holder.setValueDirectly(newValue);
+        }
     }
 
     public void addTarget(Object source, Object target, boolean setReverse) {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AbstractSingleObjectArcProperty.java Wed Oct 11 19:47:29 2006
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.property;
 
+import org.apache.cayenne.map.ObjRelationship;
 
 /**
  * A base superclass of SingleObjectArcProperty implementors.
@@ -31,6 +32,7 @@
 
     protected String complimentaryReverseArcName;
     protected ClassDescriptor targetDescriptor;
+    protected ObjRelationship relationship;
 
     public AbstractSingleObjectArcProperty(ClassDescriptor owner,
             ClassDescriptor targetDescriptor, PropertyAccessor accessor,
@@ -38,6 +40,13 @@
         super(owner, accessor);
         this.targetDescriptor = targetDescriptor;
         this.complimentaryReverseArcName = reverseName;
+        this.relationship = (ObjRelationship) owner
+                .getEntity()
+                .getRelationship(getName());
+    }
+
+    public ObjRelationship getRelationship() {
+        return relationship;
     }
 
     public void setTarget(Object source, Object target, boolean setReverse) {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ArcProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ArcProperty.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ArcProperty.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/ArcProperty.java Wed Oct 11 19:47:29 2006
@@ -19,6 +19,8 @@
 
 package org.apache.cayenne.property;
 
+import org.apache.cayenne.map.ObjRelationship;
+
 /**
  * A Property that represents an "arc" connecting source node to the target node in the
  * graph.
@@ -27,6 +29,13 @@
  * @author Andrus Adamchik
  */
 public interface ArcProperty extends Property {
+
+    /**
+     * Returns a relationship associated with this arc.
+     * 
+     * @since 3.0
+     */
+    ObjRelationship getRelationship();
 
     /**
      * Returns a complimentary reverse ArcProperty or null if no reverse arc exists.

Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AttributeProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AttributeProperty.java?view=auto&rev=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AttributeProperty.java (added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/AttributeProperty.java Wed Oct 11 19:47:29 2006
@@ -0,0 +1,32 @@
+/*****************************************************************
+ *   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.property;
+
+import org.apache.cayenne.map.ObjAttribute;
+
+/**
+ * Represents a simple object property.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public interface AttributeProperty extends Property {
+
+    ObjAttribute getAttribute();
+}

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/Property.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/Property.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/Property.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/Property.java Wed Oct 11 19:47:29 2006
@@ -47,9 +47,6 @@
      * unfaulted value holder and inject it into the object, if an object doesn't have it
      * set yet.
      */
-    // TODO: andrus 5/25/2006 - maybe move this to ArcProperty as simple properties do not
-    // support ValueHolders and ClassDescriptors are smart enough to avoid calling this
-    // method on non-arc property.
     void injectValueHolder(Object object) throws PropertyAccessException;
 
     /**

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/PropertyVisitor.java Wed Oct 11 19:47:29 2006
@@ -28,6 +28,7 @@
  */
 public interface PropertyVisitor {
 
+    // TODO: andrus, 10/11/2006 - replace this with visitAttributeProperty()
     boolean visitProperty(Property property);
 
     boolean visitSingleObjectArc(SingleObjectArcProperty property);

Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java?view=auto&rev=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java (added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/property/SimplePersistentProperty.java Wed Oct 11 19:47:29 2006
@@ -0,0 +1,68 @@
+/*****************************************************************
+ *   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.property;
+
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.map.ObjAttribute;
+
+/**
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public class SimplePersistentProperty extends SimpleProperty implements AttributeProperty {
+
+    private ObjAttribute attribute;
+
+    public SimplePersistentProperty(ClassDescriptor owner, PropertyAccessor accessor,
+            ObjAttribute attribute) {
+        super(owner, accessor);
+        this.attribute = attribute;
+    }
+
+    public ObjAttribute getAttribute() {
+        return attribute;
+    }
+
+    public Object readProperty(Object object) throws PropertyAccessException {
+        resolveFault(object);
+        return super.readProperty(object);
+    }
+
+    public void writeProperty(Object object, Object oldValue, Object newValue)
+            throws PropertyAccessException {
+        resolveFault(object);
+        super.writeProperty(object, oldValue, newValue);
+    }
+
+    void resolveFault(Object object) throws PropertyAccessException {
+        try {
+            Persistent persistent = (Persistent) object;
+            ObjectContext context = persistent.getObjectContext();
+            if (context != null) {
+                context.prepareForAccess(persistent, getName());
+            }
+        }
+        catch (ClassCastException e) {
+            throw new PropertyAccessException("Object is not a Persistent: '"
+                    + object.getClass().getName()
+                    + "'", this, object, e);
+        }
+    }
+}
\ No newline at end of file

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java Wed Oct 11 19:47:29 2006
@@ -33,6 +33,7 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
 import org.apache.cayenne.util.XMLSerializable;
@@ -56,19 +57,19 @@
     String cacheKey;
     String[] cacheGroups;
 
-    transient ObjEntity objEntity;
     transient DbEntity dbEntity;
     transient DataMap dataMap;
     transient Object lastRoot;
+    transient ClassDescriptor classDescriptor;
     transient EntityResolver lastEntityResolver;
 
     /**
-     * Copies values of this object to another SelectInfo object.
+     * Copies values of another QueryMetadata object to this object.
      */
     void copyFromInfo(QueryMetadata info) {
         this.lastEntityResolver = null;
         this.lastRoot = null;
-        this.objEntity = null;
+        this.classDescriptor = null;
         this.dbEntity = null;
         this.dataMap = null;
 
@@ -89,29 +90,31 @@
 
             this.cacheKey = cacheKey;
 
-            this.objEntity = null;
+            this.classDescriptor = null;
             this.dbEntity = null;
             this.dataMap = null;
+            
+            ObjEntity entity = null;
 
             if (root != null) {
                 if (root instanceof Class) {
-                    this.objEntity = resolver.lookupObjEntity((Class) root);
+                    entity = resolver.lookupObjEntity((Class) root);
 
-                    if (this.objEntity != null) {
-                        this.dbEntity = objEntity.getDbEntity();
-                        this.dataMap = objEntity.getDataMap();
+                    if (entity != null) {
+                        this.dbEntity = entity.getDbEntity();
+                        this.dataMap = entity.getDataMap();
                     }
                 }
                 else if (root instanceof ObjEntity) {
-                    this.objEntity = (ObjEntity) root;
-                    this.dbEntity = objEntity.getDbEntity();
-                    this.dataMap = objEntity.getDataMap();
+                    entity = (ObjEntity) root;
+                    this.dbEntity = entity.getDbEntity();
+                    this.dataMap = entity.getDataMap();
                 }
                 else if (root instanceof String) {
-                    this.objEntity = resolver.lookupObjEntity((String) root);
-                    if (this.objEntity != null) {
-                        this.dbEntity = objEntity.getDbEntity();
-                        this.dataMap = objEntity.getDataMap();
+                    entity = resolver.lookupObjEntity((String) root);
+                    if (entity != null) {
+                        this.dbEntity = entity.getDbEntity();
+                        this.dataMap = entity.getDataMap();
                     }
                 }
                 else if (root instanceof DbEntity) {
@@ -122,14 +125,18 @@
                     this.dataMap = (DataMap) root;
                 }
                 else if (root instanceof Persistent) {
-                    this.objEntity = resolver.lookupObjEntity((Persistent) root);
-                    if (this.objEntity != null) {
-                        this.dbEntity = objEntity.getDbEntity();
-                        this.dataMap = objEntity.getDataMap();
+                    entity = resolver.lookupObjEntity((Persistent) root);
+                    if (entity != null) {
+                        this.dbEntity = entity.getDbEntity();
+                        this.dataMap = entity.getDataMap();
                     }
                 }
             }
 
+            if (entity != null) {
+                this.classDescriptor = resolver.getClassDescriptor(entity.getName());
+            }
+            
             this.lastRoot = root;
             this.lastEntityResolver = resolver;
             return true;
@@ -230,7 +237,7 @@
         if (prefetchTree != null) {
             prefetchTree.encodeAsXML(encoder);
         }
-        
+
         if (cacheGroups != null && cacheGroups.length > 0) {
             StringBuffer buffer = new StringBuffer(cacheGroups[0]);
             for (int i = 1; i < cacheGroups.length; i++) {
@@ -272,7 +279,14 @@
      * @since 1.2
      */
     public ObjEntity getObjEntity() {
-        return objEntity;
+        return classDescriptor != null ? classDescriptor.getEntity() : null;
+    }
+
+    /**
+     * @since 3.0
+     */
+    public ClassDescriptor getClassDescriptor() {
+        return classDescriptor;
     }
 
     /**

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java Wed Oct 11 19:47:29 2006
@@ -23,6 +23,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 
 /**
  * A QueryMetadata implementation that returns all the defaults.
@@ -59,6 +60,10 @@
     }
 
     public ObjEntity getObjEntity() {
+        return null;
+    }
+    
+    public ClassDescriptor getClassDescriptor() {
         return null;
     }
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/ObjectIdQuery.java Wed Oct 11 19:47:29 2006
@@ -26,6 +26,7 @@
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.util.Util;
 
 /**
@@ -87,8 +88,12 @@
         if (metadata == null || metadataResolver != resolver) {
             this.metadata = new DefaultQueryMetadata() {
 
+                public ClassDescriptor getClassDescriptor() {
+                    return resolver.getClassDescriptor(objectId.getEntityName());
+                }
+                
                 public ObjEntity getObjEntity() {
-                    return resolver.lookupObjEntity(objectId.getEntityName());
+                    return getClassDescriptor().getEntity();
                 }
 
                 public boolean isFetchingDataRows() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadata.java Wed Oct 11 19:47:29 2006
@@ -23,6 +23,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 
 /**
  * Provides a common interface for accessing query metadata.
@@ -101,6 +102,11 @@
 
     public static final String CACHE_POLICY_DEFAULT = NO_CACHE;
 
+    /**
+     * @since 3.0
+     */
+    ClassDescriptor getClassDescriptor();
+    
     /**
      * Returns an ObjEntity associated with a query or null if no such entity exists.
      */

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java Wed Oct 11 19:47:29 2006
@@ -26,6 +26,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 
 /**
  * A wrapper for a QueryMetadata instance allowing that may override a subset of metadata
@@ -75,6 +76,13 @@
 
     public ObjEntity getObjEntity() {
         return info.getObjEntity();
+    }
+    
+    /**
+     * @since 3.0
+     */
+    public ClassDescriptor getClassDescriptor() {
+        return info.getClassDescriptor();
     }
 
     public String getCacheKey() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RelationshipQuery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RelationshipQuery.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RelationshipQuery.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/RelationshipQuery.java Wed Oct 11 19:47:29 2006
@@ -27,6 +27,8 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.ArcProperty;
+import org.apache.cayenne.property.ClassDescriptor;
 
 /**
  * A query that selects objects related to a given object. It is intended for fetching
@@ -45,7 +47,7 @@
 
     protected transient EntityResolver metadataResolver;
     protected transient QueryMetadata metadata;
-    protected transient ObjRelationship relationship;
+    protected transient ArcProperty arc;
 
     // exists for deserialization with Hessian
     private RelationshipQuery() {
@@ -130,7 +132,7 @@
      */
     public ObjRelationship getRelationship(EntityResolver resolver) {
         updateMetadata(resolver);
-        return relationship;
+        return arc.getRelationship();
     }
 
     void updateMetadata(EntityResolver resolver) {
@@ -142,15 +144,15 @@
                         "Can't resolve query - objectID is null.");
             }
 
-            ObjEntity entity = resolver.lookupObjEntity(objectId.getEntityName());
-            this.relationship = (ObjRelationship) entity
-                    .getRelationship(relationshipName);
+            ClassDescriptor descriptor = resolver.getClassDescriptor(objectId
+                    .getEntityName());
+            this.arc = (ArcProperty) descriptor.getProperty(relationshipName);
 
-            if (relationship == null) {
+            if (arc == null) {
                 throw new CayenneRuntimeException("No relationship named "
                         + relationshipName
                         + " found in entity "
-                        + entity.getName()
+                        + objectId.getEntityName()
                         + "; object id: "
                         + objectId);
             }
@@ -162,7 +164,11 @@
                 }
 
                 public ObjEntity getObjEntity() {
-                    return (ObjEntity) relationship.getTargetEntity();
+                    return arc.getTargetDescriptor().getEntity();
+                }
+
+                public ClassDescriptor getClassDescriptor() {
+                    return arc.getTargetDescriptor();
                 }
             };
 

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java Wed Oct 11 19:47:29 2006
@@ -25,6 +25,7 @@
 import java.util.Map;
 
 import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.ObjEntity;
 
 /**
  * @since 3.0
@@ -48,8 +49,9 @@
                 // create a unique key based on entity, SQL, and parameters
 
                 StringBuffer key = new StringBuffer();
-                if (objEntity != null) {
-                    key.append(objEntity.getName());
+                ObjEntity entity = getObjEntity();
+                if (entity != null) {
+                    key.append(entity.getName());
                 }
                 else if (dbEntity != null) {
                     key.append("db:").append(dbEntity.getName());

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/query/SelectQueryMetadata.java Wed Oct 11 19:47:29 2006
@@ -21,6 +21,7 @@
 import java.util.Iterator;
 
 import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.ObjEntity;
 
 /**
  * @since 3.0
@@ -43,8 +44,10 @@
                 // create a unique key based on entity, qualifier and ordering
 
                 StringBuffer key = new StringBuffer();
-                if (objEntity != null) {
-                    key.append(objEntity.getName());
+                
+                ObjEntity entity = getObjEntity();
+                if (entity != null) {
+                    key.append(entity.getName());
                 }
                 else if (dbEntity != null) {
                     key.append("db:").append(dbEntity.getName());

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java Wed Oct 11 19:47:29 2006
@@ -24,6 +24,7 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryMetadata;
@@ -89,6 +90,10 @@
 
             public ObjEntity getObjEntity() {
                 return metadata.getObjEntity();
+            }
+            
+            public ClassDescriptor getClassDescriptor() {
+                return metadata.getClassDescriptor();
             }
 
             public int getPageSize() {

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/RangeQuery.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/RangeQuery.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/RangeQuery.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/remote/RangeQuery.java Wed Oct 11 19:47:29 2006
@@ -24,6 +24,7 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryMetadata;
@@ -70,7 +71,7 @@
             public String getCacheKey() {
                 return cacheKey;
             }
-            
+
             public String[] getCacheGroups() {
                 return null;
             }
@@ -108,6 +109,10 @@
             }
 
             public ObjEntity getObjEntity() {
+                throw new UnsupportedOperationException();
+            }
+
+            public ClassDescriptor getClassDescriptor() {
                 throw new UnsupportedOperationException();
             }
 

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=463113&r1=463112&r2=463113
==============================================================================
--- 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 Wed Oct 11 19:47:29 2006
@@ -26,8 +26,8 @@
 import org.apache.art.Painting;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.ClassDescriptor;
+import org.apache.cayenne.property.Property;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneTestCase;
 
@@ -59,8 +59,9 @@
         DataRow s2 = new DataRow(2);
         s2.put("ARTIST_NAME", n2);
         s2.put("DATE_OF_BIRTH", new java.util.Date());
-        ObjEntity e = context.getEntityResolver().lookupObjEntity(a1);
-        DataRowUtils.mergeObjectWithSnapshot(context, e, a1, s2);
+
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Artist");
+        DataRowUtils.mergeObjectWithSnapshot(context, d, a1, s2);
 
         // name was modified, so it should not change during merge
         assertEquals(n1, a1.getArtistName());
@@ -72,10 +73,8 @@
     public void testIsToOneTargetModified() throws Exception {
         getAccessStack().createTestData(DataContextTestBase.class, "testArtists", null);
 
-        ObjEntity paintingEntity = context.getEntityResolver().lookupObjEntity(
-                Painting.class);
-        ObjRelationship toArtist = (ObjRelationship) paintingEntity
-                .getRelationship("toArtist");
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
+        Property toArtist = d.getProperty("toArtist");
 
         SelectQuery artistQ = new SelectQuery(Artist.class, Expression
                 .fromString("artistName = 'artist2'"));
@@ -109,10 +108,8 @@
         assertEquals(1, paintings.size());
         Painting p1 = (Painting) paintings.get(0);
 
-        ObjEntity paintingEntity = context.getEntityResolver().lookupObjEntity(
-                Painting.class);
-        ObjRelationship toGallery = (ObjRelationship) paintingEntity
-                .getRelationship("toGallery");
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor("Painting");
+        Property toGallery = d.getProperty("toGallery");
 
         ObjectDiff diff = context.getObjectStore().registerDiff(p1.getObjectId(), null);
         assertFalse(DataRowUtils.isToOneTargetModified(toGallery, p1, diff));

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/FlattenedRelationshipInContextTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/FlattenedRelationshipInContextTst.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/FlattenedRelationshipInContextTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/FlattenedRelationshipInContextTst.java Wed Oct 11 19:47:29 2006
@@ -24,8 +24,8 @@
 import org.apache.cayenne.Fault;
 import org.apache.cayenne.FlattenedRelationshipsTst;
 import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.property.ClassDescriptor;
+import org.apache.cayenne.property.Property;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.testdo.relationship.FlattenedTest3;
 import org.apache.cayenne.unit.RelationshipTestCase;
@@ -49,9 +49,11 @@
 
         // test that checking for modifications does not trigger a fault, and generally
         // works well
-        ObjEntity entity = context.getEntityResolver().lookupObjEntity(
-                FlattenedTest3.class);
-        ObjRelationship flattenedRel = (ObjRelationship) entity.getRelationship("toFT1");
+
+        ClassDescriptor d = context.getEntityResolver().getClassDescriptor(
+                "FlattenedTest3");
+        Property flattenedRel = d.getProperty("toFT1");
+
         ObjectDiff diff = context.getObjectStore().registerDiff(ft3.getObjectId(), null);
         assertFalse(DataRowUtils.isToOneTargetModified(flattenedRel, ft3, diff));
         assertTrue(ft3.readPropertyDirectly("toFT1") instanceof Fault);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectTreeResolver_TreeBuilderTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectTreeResolver_TreeBuilderTst.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectTreeResolver_TreeBuilderTst.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/access/ObjectTreeResolver_TreeBuilderTst.java Wed Oct 11 19:47:29 2006
@@ -32,6 +32,7 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.property.ClassDescriptor;
 import org.apache.cayenne.query.MockQueryMetadata;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.QueryMetadata;
@@ -41,23 +42,29 @@
 
     public void testBuildTreeNoPrefetches() {
 
-        final ObjEntity entity = getObjEntity("Artist");
+        final ClassDescriptor descriptor = getDomain()
+                .getEntityResolver()
+                .getClassDescriptor("Artist");
         List dataRows = new ArrayList();
         dataRows.add(new DataRow(4));
         dataRows.add(new DataRow(4));
 
         QueryMetadata metadata = new MockQueryMetadata() {
 
+            public ClassDescriptor getClassDescriptor() {
+                return descriptor;
+            }
+
             public ObjEntity getObjEntity() {
-                return entity;
+                return descriptor.getEntity();
             }
 
             public DbEntity getDbEntity() {
-                return entity.getDbEntity();
+                return getObjEntity().getDbEntity();
             }
 
             public DataMap getDataMap() {
-                return entity.getDataMap();
+                return getObjEntity().getDataMap();
             }
 
             public boolean isRefreshingObjects() {
@@ -82,13 +89,15 @@
         assertFalse(processingTree.isPartitionedByParent());
         assertTrue(processingTree.isDisjointPrefetch());
         assertSame(dataRows, processingTree.getDataRows());
-        assertSame(entity, processingTree.getResolver().getEntity());
+        assertSame(descriptor.getEntity(), processingTree.getResolver().getEntity());
         assertNull(processingTree.getIncoming());
     }
 
     public void testBuildTreeWithPrefetches() {
 
-        final ObjEntity e1 = getObjEntity("Artist");
+        final ClassDescriptor descriptor = getDomain()
+                .getEntityResolver()
+                .getClassDescriptor("Artist");
         ObjEntity e2 = getObjEntity("Painting");
         ObjEntity e3 = getObjEntity("Gallery");
         ObjEntity e4 = getObjEntity("Exhibit");
@@ -109,16 +118,20 @@
 
         QueryMetadata metadata = new MockQueryMetadata() {
 
+            public ClassDescriptor getClassDescriptor() {
+                return descriptor;
+            }
+
             public ObjEntity getObjEntity() {
-                return e1;
+                return descriptor.getEntity();
             }
 
             public DbEntity getDbEntity() {
-                return e1.getDbEntity();
+                return getObjEntity().getDbEntity();
             }
 
             public DataMap getDataMap() {
-                return e1.getDataMap();
+                return getObjEntity().getDataMap();
             }
 
             public boolean isRefreshingObjects() {
@@ -138,7 +151,7 @@
         PrefetchProcessorNode n1 = builder.buildTree(tree);
 
         assertSame(mainRows, n1.getDataRows());
-        assertSame(e1, n1.getResolver().getEntity());
+        assertSame(descriptor.getEntity(), n1.getResolver().getEntity());
 
         PrefetchProcessorNode n2 = (PrefetchProcessorNode) n1.getNode("paintingArray");
         assertNotNull(n2);

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java?view=diff&rev=463113&r1=463112&r2=463113
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java (original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java Wed Oct 11 19:47:29 2006
@@ -23,6 +23,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.property.ClassDescriptor;
 
 public class MockQueryMetadata implements QueryMetadata {
 
@@ -51,6 +52,10 @@
     }
     
     public String[] getCacheGroups() {
+        return null;
+    }
+    
+    public ClassDescriptor getClassDescriptor() {
         return null;
     }
 



Mime
View raw message