cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r721819 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/access/jdbc/ main/java/org/apache/cayenne/cache/ main/java/org/apache/cayenne/map/ main/java/org/ap...
Date Sun, 30 Nov 2008 14:21:35 GMT
Author: aadamchik
Date: Sun Nov 30 06:21:34 2008
New Revision: 721819

URL: http://svn.apache.org/viewvc?rev=721819&view=rev
Log:
CAY-1136 "Compiled" EntityResult ; Switch SelectQuery processing to use EntityResult

compiled SQLResultSetMetadata/EntityResultMetadata split from the user-editable SQLResultSet/EntityResult

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultEntityResultMetadata.java
      - copied, changed from r721818, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultResultSetMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EntityResultMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLResultSetMetadata.java
      - copied, changed from r721818, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorResultMetadata.java
Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/FieldResult.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLTranslationContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResult.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLResultSet.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/ClassDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LazyClassDescriptorDecorator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MockClassDescriptor.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQuery.java Sun Nov 30 06:21:34 2008
@@ -25,7 +25,6 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryCacheStrategy;
@@ -33,6 +32,7 @@
 import org.apache.cayenne.query.QueryRouter;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SQLActionVisitor;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -51,7 +51,7 @@
         return this;
     }
 
-    public SQLResultSet getResultSetMapping() {
+    public SQLResultSetMetadata getResultSetMapping() {
         return null;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java Sun Nov 30 06:21:34 2008
@@ -38,11 +38,10 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.SQLResultSet;
+import org.apache.cayenne.query.EntityResultMetadata;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchSelectQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
@@ -52,6 +51,7 @@
 import org.apache.cayenne.query.QueryRouter;
 import org.apache.cayenne.query.RefreshQuery;
 import org.apache.cayenne.query.RelationshipQuery;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.cayenne.reflect.LifecycleCallbackRegistry;
 import org.apache.cayenne.util.GenericResponse;
@@ -435,22 +435,14 @@
 
                 ObjectConversionStrategy converter;
 
-                SQLResultSet rsMapping = metadata.getResultSetMapping();
+                SQLResultSetMetadata rsMapping = metadata.getResultSetMapping();
                 if (rsMapping == null) {
                     converter = new SingleObjectConversionStrategy();
                 }
                 else {
 
-                    int entityResultCount = 0;
-                    int columnResultCount = 0;
-                    for (Object result : rsMapping.getResultDescriptors()) {
-                        if (result instanceof String) {
-                            columnResultCount++;
-                        }
-                        else {
-                            entityResultCount++;
-                        }
-                    }
+                    int entityResultCount = rsMapping.getEntitySegments().length;
+                    int columnResultCount = rsMapping.getScalarSegments().length;
 
                     if (entityResultCount == 1 && columnResultCount == 0) {
                         converter = new SingleObjectConversionStrategy();
@@ -602,12 +594,11 @@
         }
 
         protected List<DataRow> toNormalizedDataRows(
-                EntityResult entityMapping,
+                EntityResultMetadata entityMapping,
                 List<DataRow> dataRows) {
             List<DataRow> normalized = new ArrayList<DataRow>(dataRows.size());
 
-            Map<String, String> fields = entityMapping.getDbFields(domain
-                    .getEntityResolver());
+            Map<String, String> fields = entityMapping.getFields();
             int rowCapacity = (int) Math.ceil(fields.size() / 0.75);
 
             for (DataRow src : dataRows) {
@@ -644,10 +635,10 @@
             List<DataRow> normalized;
 
             // convert data rows to standardized format...
-            SQLResultSet rsMapping = metadata.getResultSetMapping();
+            SQLResultSetMetadata rsMapping = metadata.getResultSetMapping();
             if (rsMapping != null) {
                 // expect 1 and only 1 entityMapping...
-                EntityResult entityMapping = rsMapping.getEntityResult(0);
+                EntityResultMetadata entityMapping = rsMapping.getEntitySegment(0);
                 normalized = toNormalizedDataRows(entityMapping, mainRows);
             }
             else {
@@ -676,12 +667,12 @@
         @Override
         void convert(List<DataRow> mainRows) {
 
-            SQLResultSet rsMapping = metadata.getResultSetMapping();
+            SQLResultSetMetadata rsMapping = metadata.getResultSetMapping();
 
             int rowsLen = mainRows.size();
 
             List objects = new ArrayList(rowsLen);
-            String column = rsMapping.getColumnResult(0);
+            String column = rsMapping.getScalarSegment(0);
 
             // add scalars to the result
             for (DataRow row : mainRows) {
@@ -700,19 +691,19 @@
             int rowsLen = mainRows.size();
             List<Object[]> objects = new ArrayList<Object[]>(rowsLen);
 
-            SQLResultSet rsMapping = metadata.getResultSetMapping();
+            SQLResultSetMetadata rsMapping = metadata.getResultSetMapping();
 
             // pass 1 - init Object[]'s and resolve scalars for each row
 
-            int resultWidth = rsMapping.getResultDescriptors().size();
-            int[] entityPositions = rsMapping.getEntityResultPositions();
-            int[] columnPositions = rsMapping.getColumnResultPositions();
+            int resultWidth = rsMapping.getSegmentsCount();
+            int[] entityPositions = rsMapping.getEntitySegments();
+            int[] columnPositions = rsMapping.getScalarSegments();
 
             for (DataRow row : mainRows) {
                 Object[] resultRow = new Object[resultWidth];
                 for (int i = 0; i < columnPositions.length; i++) {
                     int pos = columnPositions[i];
-                    resultRow[pos] = row.get(rsMapping.getColumnResult(pos));
+                    resultRow[pos] = row.get(rsMapping.getScalarSegment(pos));
                 }
                 objects.add(resultRow);
             }
@@ -722,15 +713,11 @@
             List[] resultLists = new List[entityPositions.length];
             for (int i = 0; i < entityPositions.length; i++) {
                 int pos = entityPositions[i];
-                EntityResult entityMapping = rsMapping.getEntityResult(pos);
+                EntityResultMetadata entityMapping = rsMapping.getEntitySegment(pos);
                 List<DataRow> normalized = toNormalizedDataRows(entityMapping, mainRows);
 
-                ClassDescriptor classDescriptor = resolver
-                        .getClassDescriptor(entityMapping
-                                .getRootEntity(resolver)
-                                .getName());
-
-                List<Persistent> nextResult = toObjects(classDescriptor, null, normalized);
+                List<Persistent> nextResult = toObjects(entityMapping
+                        .getClassDescriptor(), null, normalized);
 
                 for (int j = 0; j < rowsLen; j++) {
                     objects.get(j)[pos] = nextResult.get(j);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ObjectStore.java Sun Nov 30 06:21:34 2008
@@ -48,13 +48,13 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryCacheStrategy;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.RefreshQuery;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.AttributeProperty;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.cayenne.reflect.PropertyVisitor;
@@ -1161,7 +1161,7 @@
             return cacheKey;
         }
 
-        public SQLResultSet getResultSetMapping() {
+        public SQLResultSetMetadata getResultSetMapping() {
             return null;
         }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLAction.java Sun Nov 30 06:21:34 2008
@@ -59,8 +59,8 @@
                 .getEjbqlTranslatorFactory();
         final EJBQLTranslationContext context = new EJBQLTranslationContext(
                 entityResolver,
+                query,
                 compiledExpression,
-                query.getParameters(),
                 translatorFactory);
 
         compiledExpression.getExpression().visit(new EJBQLBaseVisitor(false) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java Sun Nov 30 06:21:34 2008
@@ -57,7 +57,7 @@
 
         Map<String, String> xfields = null;
         if (context.isAppendingResultColumns()) {
-            xfields = context.nextEntityResult().getDbFields(context.getEntityResolver());
+            xfields = context.nextEntityResult().getFields();
         }
 
         // assign whatever we have to a final ivar so that it can be accessed within

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLTranslationContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLTranslationContext.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLTranslationContext.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLTranslationContext.java Sun Nov 30 06:21:34 2008
@@ -29,8 +29,9 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.EntityResult;
-import org.apache.cayenne.map.SQLResultSet;
+import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.EntityResultMetadata;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
@@ -45,6 +46,7 @@
     private Map<Object, Object> parameters;
     private EJBQLTranslatorFactory translatorFactory;
     private EntityResolver entityResolver;
+    private SQLResultSetMetadata resultSetMetadata;
 
     private Map<String, String> tableAliases;
     private Map<String, Object> boundParameters;
@@ -61,14 +63,15 @@
     // not.
     private boolean appendingResultColumns;
 
-    public EJBQLTranslationContext(EntityResolver entityResolver,
-            EJBQLCompiledExpression compiledExpression, Map<Object, Object> parameters,
+    public EJBQLTranslationContext(EntityResolver entityResolver, EJBQLQuery query,
+            EJBQLCompiledExpression compiledExpression,
             EJBQLTranslatorFactory translatorFactory) {
 
         this.entityResolver = entityResolver;
         this.compiledExpression = compiledExpression;
+        this.resultSetMetadata = query.getMetaData(entityResolver).getResultSetMapping();
 
-        this.parameters = parameters;
+        this.parameters = query.getParameters();
         this.translatorFactory = translatorFactory;
         this.usingAliases = true;
 
@@ -377,15 +380,14 @@
     /**
      * Returns a positional EntityResult, incrementing position index on each call.
      */
-    EntityResult nextEntityResult() {
+    EntityResultMetadata nextEntityResult() {
 
-        SQLResultSet resultSetMapping = compiledExpression.getResultSet();
-        if (resultSetMapping == null) {
+        if (resultSetMetadata == null) {
             throw new EJBQLException(
                     "No result set mapping exists for expression, can't map EntityResult");
         }
 
-        return resultSetMapping.getEntityResult(resultDescriptorPosition++);
+        return resultSetMetadata.getEntitySegment(resultDescriptorPosition++);
     }
 
     /**
@@ -393,13 +395,12 @@
      */
     String nextColumnAlias() {
 
-        SQLResultSet resultSetMapping = compiledExpression.getResultSet();
-        if (resultSetMapping == null) {
+        if (resultSetMetadata == null) {
             throw new EJBQLException(
                     "No result set mapping exists for expression, can't map column aliases");
         }
 
-        return resultSetMapping.getColumnResult(resultDescriptorPosition++);
+        return resultSetMetadata.getScalarSegment(resultDescriptorPosition++);
     }
 
     boolean isAppendingResultColumns() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/cache/NestedQueryCache.java Sun Nov 30 06:21:34 2008
@@ -25,11 +25,11 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryCacheStrategy;
 import org.apache.cayenne.query.QueryMetadata;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -196,7 +196,7 @@
             return mdDelegate.getProcedure();
         }
 
-        public SQLResultSet getResultSetMapping() {
+        public SQLResultSetMetadata getResultSetMapping() {
             return mdDelegate.getResultSetMapping();
         }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResult.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResult.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResult.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/EntityResult.java Sun Nov 30 06:21:34 2008
@@ -24,6 +24,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cayenne.util.ToStringBuilder;
+
 /**
  * A metadata object that provides mapping of a set of result columns to an ObjEntity.
  * Used by {@link SQLResultSet}.
@@ -72,7 +74,7 @@
         return dbFields;
     }
 
-    public ObjEntity getRootEntity(EntityResolver resolver) {
+    private ObjEntity getRootEntity(EntityResolver resolver) {
         if (entityName != null) {
             return resolver.getObjEntity(entityName);
         }
@@ -125,4 +127,46 @@
     public Collection<FieldResult> getFields() {
         return fields != null ? fields : Collections.EMPTY_LIST;
     }
+
+    class FieldResult {
+
+        protected String entityName;
+        protected String attributeName;
+        protected String column;
+        protected boolean dbAttribute;
+
+        FieldResult(String entityName, String attributeName, String column,
+                boolean dbAttribute) {
+
+            this.entityName = entityName;
+            this.attributeName = attributeName;
+            this.column = column;
+            this.dbAttribute = dbAttribute;
+        }
+
+        public String getEntityName() {
+            return entityName;
+        }
+
+        public String getAttributeName() {
+            return attributeName;
+        }
+
+        public String getColumn() {
+            return column;
+        }
+
+        public boolean isDbAttribute() {
+            return dbAttribute;
+        }
+
+        @Override
+        public String toString() {
+            return new ToStringBuilder(this)
+                    .append("attributeName", attributeName)
+                    .append("column", column)
+                    .append("db", dbAttribute)
+                    .toString();
+        }
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLResultSet.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLResultSet.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLResultSet.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/SQLResultSet.java Sun Nov 30 06:21:34 2008
@@ -22,7 +22,6 @@
 import java.util.Collections;
 import java.util.List;
 
-
 /**
  * A metadata object that defines how a row in a result set can be converted to result
  * objects. SQLResultSet can map to a single scalar, a single entity or a mix of scalars
@@ -65,72 +64,6 @@
         return resultDescriptors != null ? resultDescriptors : Collections.EMPTY_LIST;
     }
 
-    public int[] getEntityResultPositions() {
-        if (resultDescriptors == null) {
-            return new int[0];
-        }
-
-        int[] positions = new int[resultDescriptors.size()];
-        int j = 0;
-        for (int i = 0; i < positions.length; i++) {
-            if (resultDescriptors.get(i) instanceof EntityResult) {
-                positions[j++] = i;
-            }
-        }
-
-        int[] trimmed = new int[j];
-        System.arraycopy(positions, 0, trimmed, 0, j);
-        return trimmed;
-    }
-
-    public int[] getColumnResultPositions() {
-        if (resultDescriptors == null) {
-            return new int[0];
-        }
-
-        int[] positions = new int[resultDescriptors.size()];
-        int j = 0;
-        for (int i = 0; i < positions.length; i++) {
-            if (resultDescriptors.get(i) instanceof String) {
-                positions[j++] = i;
-            }
-        }
-
-        int[] trimmed = new int[j];
-        System.arraycopy(positions, 0, trimmed, 0, j);
-        return trimmed;
-    }
-
-    public EntityResult getEntityResult(int position) {
-        if (resultDescriptors == null) {
-            throw new IndexOutOfBoundsException("Invalid EntityResult index: " + position);
-        }
-
-        Object result = resultDescriptors.get(position);
-        if (result instanceof EntityResult) {
-            return (EntityResult) result;
-        }
-
-        throw new IllegalArgumentException("Result at position "
-                + position
-                + " is not an entity result");
-    }
-
-    public String getColumnResult(int position) {
-        if (resultDescriptors == null) {
-            throw new IndexOutOfBoundsException("Invalid column index: " + position);
-        }
-
-        Object result = resultDescriptors.get(position);
-        if (result instanceof String) {
-            return (String) result;
-        }
-
-        throw new IllegalArgumentException("Result at position "
-                + position
-                + " is not a column result");
-    }
-
     public void addEntityResult(EntityResult entityResult) {
         if (resultDescriptors == null) {
             resultDescriptors = new ArrayList<Object>(3);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java Sun Nov 30 06:21:34 2008
@@ -32,7 +32,6 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
@@ -55,8 +54,8 @@
     PrefetchTreeNode prefetchTree;
     String cacheKey;
     String[] cacheGroups;
-    SQLResultSet resultSetMapping;
-
+    
+    transient SQLResultSetMetadata resultSetMapping;
     transient DbEntity dbEntity;
     transient DataMap dataMap;
     transient Object lastRoot;
@@ -291,14 +290,7 @@
     /**
      * @since 3.0
      */
-    void setResultSetMapping(SQLResultSet resultSetMapping) {
-        this.resultSetMapping = resultSetMapping;
-    }
-
-    /**
-     * @since 3.0
-     */
-    public SQLResultSet getResultSetMapping() {
+    public SQLResultSetMetadata getResultSetMapping() {
         return resultSetMapping;
     }
 

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultEntityResultMetadata.java (from r721818, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultEntityResultMetadata.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultEntityResultMetadata.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java&r1=721818&r2=721819&rev=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultEntityResultMetadata.java Sun Nov 30 06:21:34 2008
@@ -18,36 +18,29 @@
  ****************************************************************/
 package org.apache.cayenne.query;
 
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.SQLResultSet;
+import java.util.Map;
+
+import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
- * A metadata object for the {@link EJBQLQuery}.
- * 
  * @since 3.0
  */
-class EJBQLQueryMetadata extends BaseQueryMetadata {
+class DefaultEntityResultMetadata implements EntityResultMetadata {
 
-    private transient SQLResultSet resultSetMapping;
+    private ClassDescriptor classDescriptor;
+    private Map<String, String> fields;
 
-    void setResultSetMapping(SQLResultSet resultSetMapping) {
-        this.resultSetMapping = resultSetMapping;
+    DefaultEntityResultMetadata(ClassDescriptor classDescriptor,
+            Map<String, String> fields) {
+        this.classDescriptor = classDescriptor;
+        this.fields = fields;
     }
 
-    @Override
-    public SQLResultSet getResultSetMapping() {
-        return resultSetMapping;
+    public ClassDescriptor getClassDescriptor() {
+        return classDescriptor;
     }
 
-    boolean resolve(EntityResolver resolver, EJBQLQuery query) {
-        EJBQLCompiledExpression expression = query.getExpression(resolver);
-        setResultSetMapping(expression.getResultSet());
-        
-        ObjEntity root = expression.getRootDescriptor().getEntity();
-
-        // TODO: andrus, 4/3/2007 - generate cache key based on EJBQL statement
-        return super.resolve(root, resolver, null);
+    public Map<String, String> getFields() {
+        return fields;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultQueryMetadata.java Sun Nov 30 06:21:34 2008
@@ -26,7 +26,6 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -61,7 +60,7 @@
     /**
      * @since 3.0
      */
-    public SQLResultSet getResultSetMapping() {
+    public SQLResultSetMetadata getResultSetMapping() {
         return null;
     }
 

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultResultSetMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultResultSetMetadata.java?rev=721819&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultResultSetMetadata.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/DefaultResultSetMetadata.java Sun Nov 30 06:21:34 2008
@@ -0,0 +1,122 @@
+/*****************************************************************
+ *   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.query;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.EntityResult;
+import org.apache.cayenne.map.SQLResultSet;
+import org.apache.cayenne.reflect.ClassDescriptor;
+
+/**
+ * A SQLResultSetMetadata implementation based on {@link SQLResultSet}.
+ * 
+ * @since 3.0
+ */
+class DefaultResultSetMetadata implements SQLResultSetMetadata {
+
+    private List<Object> segments;
+    private int[] scalarSegments;
+    private int[] entitySegments;
+
+    DefaultResultSetMetadata(SQLResultSet resultSet, EntityResolver resolver) {
+        List<Object> descriptors = resultSet.getResultDescriptors();
+
+        this.segments = new ArrayList<Object>(descriptors.size());
+
+        int[] scalarSegments = new int[descriptors.size()];
+        int[] entitySegments = new int[descriptors.size()];
+
+        int ss = 0, es = 0;
+        for (int i = 0; i < descriptors.size(); i++) {
+
+            Object descriptor = descriptors.get(i);
+            if (descriptor instanceof String) {
+                segments.add(descriptor);
+                scalarSegments[ss++] = i;
+            }
+            else if (descriptor instanceof EntityResult) {
+                EntityResult entityResult = (EntityResult) descriptor;
+                Map<String, String> fields = entityResult.getDbFields(resolver);
+
+                String entityName = entityResult.getEntityName();
+                if (entityName == null) {
+                    entityName = resolver
+                            .lookupObjEntity(entityResult.getEntityClass())
+                            .getName();
+                }
+
+                ClassDescriptor classDescriptor = resolver.getClassDescriptor(entityName);
+                segments.add(new DefaultEntityResultMetadata(classDescriptor, fields));
+                entitySegments[es++] = i;
+            }
+            else {
+                throw new IllegalArgumentException(
+                        "Unsupported result set descriptor type: " + descriptor);
+            }
+        }
+
+        this.scalarSegments = trim(scalarSegments, ss);
+        this.entitySegments = trim(entitySegments, es);
+    }
+
+    private int[] trim(int[] array, int size) {
+        int[] trimmed = new int[size];
+        System.arraycopy(array, 0, trimmed, 0, size);
+        return trimmed;
+    }
+
+    public EntityResultMetadata getEntitySegment(int position) {
+        Object result = segments.get(position);
+        if (result instanceof EntityResultMetadata) {
+            return (EntityResultMetadata) result;
+        }
+
+        throw new IllegalArgumentException("Segment at position "
+                + position
+                + " is not an entity segment");
+    }
+
+    public int[] getEntitySegments() {
+        return entitySegments;
+    }
+
+    public String getScalarSegment(int position) {
+
+        Object result = segments.get(position);
+        if (result instanceof String) {
+            return (String) result;
+        }
+
+        throw new IllegalArgumentException("Segment at position "
+                + position
+                + " is not a scalar segment");
+    }
+
+    public int[] getScalarSegments() {
+        return scalarSegments;
+    }
+
+    public int getSegmentsCount() {
+        return segments.size();
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java Sun Nov 30 06:21:34 2008
@@ -21,7 +21,6 @@
 import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.SQLResultSet;
 
 /**
  * A metadata object for the {@link EJBQLQuery}.
@@ -30,21 +29,13 @@
  */
 class EJBQLQueryMetadata extends BaseQueryMetadata {
 
-    private transient SQLResultSet resultSetMapping;
-
-    void setResultSetMapping(SQLResultSet resultSetMapping) {
-        this.resultSetMapping = resultSetMapping;
-    }
-
-    @Override
-    public SQLResultSet getResultSetMapping() {
-        return resultSetMapping;
-    }
-
     boolean resolve(EntityResolver resolver, EJBQLQuery query) {
         EJBQLCompiledExpression expression = query.getExpression(resolver);
-        setResultSetMapping(expression.getResultSet());
-        
+
+        resultSetMapping = expression.getResultSet() != null
+                ? new DefaultResultSetMetadata(expression.getResultSet(), resolver)
+                : null;
+
         ObjEntity root = expression.getRootDescriptor().getEntity();
 
         // TODO: andrus, 4/3/2007 - generate cache key based on EJBQL statement

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EntityResultMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EntityResultMetadata.java?rev=721819&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EntityResultMetadata.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EntityResultMetadata.java Sun Nov 30 06:21:34 2008
@@ -0,0 +1,36 @@
+/*****************************************************************
+ *   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.query;
+
+import java.util.Map;
+
+import org.apache.cayenne.map.EntityResult;
+import org.apache.cayenne.reflect.ClassDescriptor;
+
+/**
+ * A "compiled" version of a {@link EntityResult} descriptor.
+ * 
+ * @since 3.0
+ */
+public interface EntityResultMetadata {
+
+    ClassDescriptor getClassDescriptor();
+
+    Map<String, String> getFields();
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadata.java Sun Nov 30 06:21:34 2008
@@ -25,7 +25,6 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -299,5 +298,5 @@
      * 
      * @since 3.0
      */
-    SQLResultSet getResultSetMapping();
+    SQLResultSetMetadata getResultSetMapping();
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryMetadataWrapper.java Sun Nov 30 06:21:34 2008
@@ -26,7 +26,6 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -65,7 +64,7 @@
     /**
      * @since 3.0
      */
-    public SQLResultSet getResultSetMapping() {
+    public SQLResultSetMetadata getResultSetMapping() {
         return info.getResultSetMapping();
     }
 

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLResultSetMetadata.java (from r721818, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLResultSetMetadata.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLResultSetMetadata.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java&r1=721818&r2=721819&rev=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/EJBQLQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLResultSetMetadata.java Sun Nov 30 06:21:34 2008
@@ -18,36 +18,25 @@
  ****************************************************************/
 package org.apache.cayenne.query;
 
-import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
-import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.SQLResultSet;
 
 /**
- * A metadata object for the {@link EJBQLQuery}.
+ * A "compiled" version of a {@link SQLResultSet} descriptor.
  * 
  * @since 3.0
  */
-class EJBQLQueryMetadata extends BaseQueryMetadata {
+public interface SQLResultSetMetadata {
 
-    private transient SQLResultSet resultSetMapping;
+    /**
+     * Returns a number of scalar or entity segments in the result set.
+     */
+    int getSegmentsCount();
 
-    void setResultSetMapping(SQLResultSet resultSetMapping) {
-        this.resultSetMapping = resultSetMapping;
-    }
-
-    @Override
-    public SQLResultSet getResultSetMapping() {
-        return resultSetMapping;
-    }
-
-    boolean resolve(EntityResolver resolver, EJBQLQuery query) {
-        EJBQLCompiledExpression expression = query.getExpression(resolver);
-        setResultSetMapping(expression.getResultSet());
-        
-        ObjEntity root = expression.getRootDescriptor().getEntity();
-
-        // TODO: andrus, 4/3/2007 - generate cache key based on EJBQL statement
-        return super.resolve(root, resolver, null);
-    }
+    int[] getScalarSegments();
+
+    int[] getEntitySegments();
+
+    EntityResultMetadata getEntitySegment(int position);
+
+    String getScalarSegment(int position);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java Sun Nov 30 06:21:34 2008
@@ -39,8 +39,7 @@
 
 /**
  * A query that executes unchanged (except for template preprocessing) "raw" SQL specified
- * by the user.
- * <h3>Template Script</h3>
+ * by the user. <h3>Template Script</h3>
  * <p>
  * SQLTemplate stores a dynamic template for the SQL query that supports parameters and
  * customization using Velocity scripting language. The most straightforward use of
@@ -50,7 +49,6 @@
  * <pre>
  *                  SELECT ID, NAME FROM SOME_TABLE WHERE NAME LIKE $a
  * </pre>
- * 
  * <p>
  * <i>For advanced scripting options see "Scripting SQLTemplate" chapter in the User
  * Guide. </i>
@@ -97,6 +95,7 @@
     protected Map<String, String> templates;
     protected Map<String, ?>[] parameters;
     protected String columnNamesCapitalization;
+    protected SQLResultSet resultSet;
 
     SQLTemplateMetadata metaData = new SQLTemplateMetadata();
 
@@ -378,7 +377,7 @@
     public void setFetchLimit(int fetchLimit) {
         this.metaData.setFetchLimit(fetchLimit);
     }
-    
+
     /**
      * @since 3.0
      */
@@ -411,8 +410,8 @@
 
     /**
      * @deprecated since 3.0. With introduction of the cache strategies this setting is
-     *            redundant, although it is still being taken into account. It will be
-     *            removed in the later versions of Cayenne.
+     *             redundant, although it is still being taken into account. It will be
+     *             removed in the later versions of Cayenne.
      */
     public boolean isRefreshingObjects() {
         return metaData.isRefreshingObjects();
@@ -420,8 +419,8 @@
 
     /**
      * @deprecated since 3.0. With introduction of the cache strategies this setting is
-     *            redundant, although it is still being taken into account. It will be
-     *            removed in the later versions of Cayenne.
+     *             redundant, although it is still being taken into account. It will be
+     *             removed in the later versions of Cayenne.
      */
     public void setRefreshingObjects(boolean flag) {
         // noop
@@ -513,7 +512,9 @@
      * have one.
      */
     public Map<String, ?> getParameters() {
-        Map<String, ?> map = (parameters != null && parameters.length > 0) ? parameters[0] : null;
+        Map<String, ?> map = (parameters != null && parameters.length > 0)
+                ? parameters[0]
+                : null;
         return (map != null) ? map : Collections.EMPTY_MAP;
     }
 
@@ -530,9 +531,8 @@
             // serializable with Hessian...
             this.parameters = new Map[parameters.length];
             for (int i = 0; i < parameters.length; i++) {
-                this.parameters[i] = parameters[i] != null
-                        ? new HashMap<String, Object>(parameters[i])
-                        : new HashMap<String, Object>();
+                this.parameters[i] = parameters[i] != null ? new HashMap<String, Object>(
+                        parameters[i]) : new HashMap<String, Object>();
             }
         }
     }
@@ -601,9 +601,9 @@
      * Cayenne column mapping strategy (e.g. all column names in uppercase) is portable
      * across database engines that can have varying default capitalization. Default
      * (null) value indicates that column names provided in result set are used unchanged.
-     * <p/> Note that while a non-default setting is useful for queries that do not rely
-     * on a #result directive to describe columns, it works for all SQLTemplates the same
-     * way.
+     * <p/>
+     * Note that while a non-default setting is useful for queries that do not rely on a
+     * #result directive to describe columns, it works for all SQLTemplates the same way.
      * 
      * @param columnNameCapitalization Can be null of one of
      *            {@link #LOWERCASE_COLUMN_NAMES} or {@link #UPPERCASE_COLUMN_NAMES}.
@@ -620,7 +620,14 @@
      * 
      * @since 3.0
      */
-    public void setResultSet(SQLResultSet resultSetMapping) {
-        metaData.setResultSetMapping(resultSetMapping);
+    public void setResultSet(SQLResultSet resultSet) {
+        this.resultSet = resultSet;
+    }
+
+    /**
+     * @since 3.0
+     */
+    public SQLResultSet getResultSet() {
+        return resultSet;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplateMetadata.java Sun Nov 30 06:21:34 2008
@@ -35,6 +35,10 @@
 
         if (super.resolve(root, resolver, null)) {
 
+            resultSetMapping = query.getResultSet() != null
+                    ? new DefaultResultSetMetadata(query.getResultSet(), resolver)
+                    : null;
+
             // generate unique cache key...
             if (QueryCacheStrategy.NO_CACHE == getCacheStrategy()) {
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/ClassDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/ClassDescriptor.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/ClassDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/ClassDescriptor.java Sun Nov 30 06:21:34 2008
@@ -27,6 +27,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.EntityResultMetadata;
 
 /**
  * A runtime descriptor of an persistent class.
@@ -53,12 +54,12 @@
     Collection<DbEntity> getRootDbEntities();
 
     /**
-     * Returns the EntityResult that describes the mapping of the ResultSet when entity
-     * data is fetched.
+     * Returns the EntityResultMetadata that describes the mapping of the ResultSet when
+     * entity data is fetched.
      * 
      * @since 3.0
      */
-    EntityResult getEntityResult();
+    EntityResultMetadata getEntityResultMetadata();
 
     /**
      * Returns a class mapped by this descriptor.

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LazyClassDescriptorDecorator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LazyClassDescriptorDecorator.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LazyClassDescriptorDecorator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/LazyClassDescriptorDecorator.java Sun Nov 30 06:21:34 2008
@@ -24,8 +24,8 @@
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.EntityResultMetadata;
 
 /**
  * A ClassDescriptor wrapper that compiles decorated descriptor lazily on first access.
@@ -83,9 +83,9 @@
         return descriptor.getRootDbEntities();
     }
 
-    public EntityResult getEntityResult() {
+    public EntityResultMetadata getEntityResultMetadata() {
         checkDescriptorInitialized();
-        return descriptor.getEntityResult();
+        return descriptor.getEntityResultMetadata();
     }
 
     public Class<?> getObjectClass() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptor.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptor.java Sun Nov 30 06:21:34 2008
@@ -30,10 +30,10 @@
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.query.EntityResultMetadata;
 import org.apache.commons.collections.IteratorUtils;
 
 /**
@@ -58,7 +58,7 @@
 
     protected ObjEntity entity;
     protected Collection<DbEntity> rootDbEntities;
-    protected EntityResult entityResult;
+    protected EntityResultMetadata entityResultMetadata;
 
     // combines declared and super properties
     protected Collection<Property> idProperties;
@@ -178,13 +178,13 @@
     public Collection<DbEntity> getRootDbEntities() {
         return rootDbEntities;
     }
-    
-    public EntityResult getEntityResult() {
-        return entityResult;
-    }
-    
-    public void setEntityResult(EntityResult entityResult) {
-        this.entityResult = entityResult;
+
+    public EntityResultMetadata getEntityResultMetadata() {
+        return entityResultMetadata;
+    }
+
+    public void setEntityResultMetadata(EntityResultMetadata entityResultMetadata) {
+        this.entityResultMetadata = entityResultMetadata;
     }
 
     public boolean isFault(Object object) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorFactory.java Sun Nov 30 06:21:34 2008
@@ -32,7 +32,6 @@
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.EmbeddedAttribute;
 import org.apache.cayenne.map.EntityInheritanceTree;
-import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -134,7 +133,7 @@
         indexRootDbEntities(descriptor, inheritanceTree);
 
         indexSuperclassProperties(descriptor);
-        indexEntityResult(descriptor);
+        indexEntityResultMetadata(descriptor);
 
         return descriptor;
     }
@@ -318,14 +317,15 @@
         }
     }
 
-    protected void indexEntityResult(PersistentDescriptor descriptor) {
+    protected void indexEntityResultMetadata(PersistentDescriptor descriptor) {
 
         if (descriptor.getRootDbEntities().isEmpty()) {
             // client descriptor?
             return;
         }
 
-        final EntityResult entityResult = new EntityResult(descriptor.getObjectClass());
+        final PersistentDescriptorResultMetadata resultMetadata = new PersistentDescriptorResultMetadata(
+                descriptor);
         final Set<String> visited = new HashSet<String>();
 
         PropertyVisitor visitor = new PropertyVisitor() {
@@ -333,7 +333,7 @@
             public boolean visitAttribute(AttributeProperty property) {
                 ObjAttribute oa = property.getAttribute();
                 if (visited.add(oa.getDbAttributePath())) {
-                    entityResult.addObjectField(
+                    resultMetadata.addObjectField(
                             oa.getEntity().getName(),
                             oa.getName(),
                             oa.getDbAttributePath());
@@ -352,7 +352,7 @@
                 for (DbJoin join : dbRel.getJoins()) {
                     DbAttribute src = join.getSource();
                     if (src.isForeignKey() && visited.add(src.getName())) {
-                        entityResult.addDbField(src.getName(), src.getName());
+                        resultMetadata.addDbField(src.getName(), src.getName());
                     }
                 }
 
@@ -365,7 +365,7 @@
         // append id columns ... (some may have been appended already via relationships)
         for (String pkName : descriptor.getEntity().getPrimaryKeyNames()) {
             if (visited.add(pkName)) {
-                entityResult.addDbField(pkName, pkName);
+                resultMetadata.addDbField(pkName, pkName);
             }
         }
 
@@ -375,11 +375,11 @@
             DbAttribute column = discriminatorColumns.next();
 
             if (visited.add(column.getName())) {
-                entityResult.addDbField(column.getName(), column.getName());
+                resultMetadata.addDbField(column.getName(), column.getName());
             }
         }
 
-        descriptor.setEntityResult(entityResult);
+        descriptor.setEntityResultMetadata(resultMetadata);
     }
 
     /**

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorResultMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorResultMetadata.java?rev=721819&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorResultMetadata.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/reflect/PersistentDescriptorResultMetadata.java Sun Nov 30 06:21:34 2008
@@ -0,0 +1,76 @@
+/*****************************************************************
+ *   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.reflect;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.EntityResultMetadata;
+
+/**
+ * @since 3.0
+ */
+class PersistentDescriptorResultMetadata implements EntityResultMetadata {
+
+    ClassDescriptor classDescriptor;
+    Map<String, String> fields;
+
+    PersistentDescriptorResultMetadata(ClassDescriptor classDescriptor) {
+        this.classDescriptor = classDescriptor;
+
+        // preserve field addition order by using linked map.
+        this.fields = new LinkedHashMap<String, String>();
+    }
+
+    public ClassDescriptor getClassDescriptor() {
+        return classDescriptor;
+    }
+
+    public Map<String, String> getFields() {
+        return fields;
+    }
+
+    void addObjectField(String attributeName, String column) {
+        ObjEntity entity = classDescriptor.getEntity();
+
+        ObjAttribute attribute = (ObjAttribute) entity.getAttribute(attributeName);
+        fields.put(attribute.getDbAttributePath(), column);
+    }
+
+    /**
+     * Adds a result set column mapping for a single object property of a specified entity
+     * that may differ from the root entity if inheritance is involved.
+     */
+    void addObjectField(String entityName, String attributeName, String column) {
+        ObjEntity entity = classDescriptor.getEntity().getDataMap().getObjEntity(
+                entityName);
+
+        ObjAttribute attribute = (ObjAttribute) entity.getAttribute(attributeName);
+        fields.put(attribute.getDbAttributePath(), column);
+    }
+
+    /**
+     * Adds a result set column mapping for a single DbAttribute.
+     */
+    void addDbField(String dbAttributeName, String column) {
+        fields.put(dbAttributeName, column);
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalQuery.java Sun Nov 30 06:21:34 2008
@@ -26,7 +26,6 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryCacheStrategy;
@@ -34,6 +33,7 @@
 import org.apache.cayenne.query.QueryRouter;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SQLActionVisitor;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -71,7 +71,7 @@
                 return cacheKey;
             }
 
-            public SQLResultSet getResultSetMapping() {
+            public SQLResultSetMetadata getResultSetMapping() {
                 return metadata.getResultSetMapping();
             }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/IncrementalSelectQuery.java Sun Nov 30 06:21:34 2008
@@ -28,7 +28,6 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.Ordering;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
@@ -37,6 +36,7 @@
 import org.apache.cayenne.query.QueryRouter;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SQLActionVisitor;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.reflect.ClassDescriptor;
 import org.apache.cayenne.util.XMLEncoder;
@@ -79,7 +79,7 @@
                 return cacheKey;
             }
 
-            public SQLResultSet getResultSetMapping() {
+            public SQLResultSetMetadata getResultSetMapping() {
                 return metadata.getResultSetMapping();
             }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/remote/RangeQuery.java Sun Nov 30 06:21:34 2008
@@ -26,7 +26,6 @@
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryCacheStrategy;
@@ -34,6 +33,7 @@
 import org.apache.cayenne.query.QueryRouter;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SQLActionVisitor;
+import org.apache.cayenne.query.SQLResultSetMetadata;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
@@ -76,7 +76,7 @@
                 return originatingQuery;
             }
 
-            public SQLResultSet getResultSetMapping() {
+            public SQLResultSetMetadata getResultSetMapping() {
                 return null;
             }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java Sun Nov 30 06:21:34 2008
@@ -25,6 +25,7 @@
 import org.apache.cayenne.ejbql.EJBQLCompiledExpression;
 import org.apache.cayenne.ejbql.EJBQLParser;
 import org.apache.cayenne.ejbql.EJBQLParserFactory;
+import org.apache.cayenne.query.EJBQLQuery;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.unit.CayenneCase;
 
@@ -34,16 +35,22 @@
         return translateSelect(ejbql, Collections.EMPTY_MAP);
     }
 
-    private SQLTemplate translateSelect(String ejbql, Map<Object, Object> parameters) {
+    private SQLTemplate translateSelect(
+            String ejbql,
+            final Map<Object, Object> queryParameters) {
         EJBQLParser parser = EJBQLParserFactory.getParser();
         EJBQLCompiledExpression select = parser.compile(ejbql, getDomain()
                 .getEntityResolver());
+        EJBQLQuery query = new EJBQLQuery(ejbql) {
 
-        EJBQLTranslationContext tr = new EJBQLTranslationContext(
-                getDomain().getEntityResolver(),
-                select,
-                parameters,
-                new JdbcEJBQLTranslatorFactory());
+            @Override
+            public Map<Object, Object> getParameters() {
+                return queryParameters;
+            }
+        };
+
+        EJBQLTranslationContext tr = new EJBQLTranslationContext(getDomain()
+                .getEntityResolver(), query, select, new JdbcEJBQLTranslatorFactory());
         select.getExpression().visit(new EJBQLSelectTranslator(tr));
         return tr.getQuery();
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/MockQueryMetadata.java Sun Nov 30 06:21:34 2008
@@ -25,12 +25,11 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.SQLResultSet;
 import org.apache.cayenne.reflect.ClassDescriptor;
 
 public class MockQueryMetadata implements QueryMetadata {
     
-    public SQLResultSet getResultSetMapping() {
+    public SQLResultSetMetadata getResultSetMapping() {
         return null;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MockClassDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MockClassDescriptor.java?rev=721819&r1=721818&r2=721819&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MockClassDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/reflect/MockClassDescriptor.java Sun Nov 30 06:21:34 2008
@@ -26,8 +26,8 @@
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.EntityResultMetadata;
 
 public class MockClassDescriptor implements ClassDescriptor {
 
@@ -38,11 +38,11 @@
     public ObjEntity getEntity() {
         return null;
     }
-    
-    public EntityResult getEntityResult() {
+
+    public EntityResultMetadata getEntityResultMetadata() {
         return null;
     }
-    
+
     /**
      * @since 3.0
      */



Mime
View raw message