cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r726053 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ framework/cayenn...
Date Fri, 12 Dec 2008 15:42:48 GMT
Author: aadamchik
Date: Fri Dec 12 07:42:48 2008
New Revision: 726053

URL: http://svn.apache.org/viewvc?rev=726053&view=rev
Log:
CAY-1147 Remove id reading functionality from ResultIterator

removed all deprecated methods from ResultIterator
removed kludges from IncrementalFaultList that performed query casts to do query-specific processing and other such bad things

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/DistinctResultIterator.java
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/LimitResultIterator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/util/DistinctResultIterator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Fri Dec 12 07:42:48 2008
@@ -17,6 +17,7 @@
 CAY-1140 Store ObjEntity name in the DataRow
 CAY-1142 (Single table) Inheritance and Paginated lists 
 CAY-1146 Move User properties API to ObjectContext & BaseContext
+CAY-1147 Remove id reading functionality from ResultIterator
 
 BugFixes Since M5:
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/IncrementalFaultList.java Fri Dec 12 07:42:48 2008
@@ -33,7 +33,6 @@
 import org.apache.cayenne.Persistent;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.QueryMetadata;
@@ -69,7 +68,7 @@
      * Stores a hint allowing to distinguish data rows from unfetched ids when the query
      * fetches data rows.
      */
-    protected int rowWidth;
+    protected int idWidth;
 
     private IncrementalListHelper helper;
 
@@ -97,7 +96,7 @@
         this.dataContext = list.dataContext;
         this.rootEntity = list.rootEntity;
         this.maxFetchSize = list.maxFetchSize;
-        this.rowWidth = list.rowWidth;
+        this.idWidth = list.idWidth;
         this.helper = list.helper;
         elements = Collections.synchronizedList(new ArrayList<Object>());
     }
@@ -134,33 +133,10 @@
         this.internalQuery.setPrefetchTree(metadata.getPrefetchTree());
 
         this.helper = createHelper(metadata);
-
-        boolean resolvesFirstPage = true;
-
-        if (!metadata.isFetchingDataRows() && (query instanceof SelectQuery)) {
-            SelectQuery select = (SelectQuery) query;
-
-            // optimize SelectQuery:
-            // * just select ID columns - this gives a 5-10x speedup
-            // * strip prefetches as they blow the iterated result, and are actually not
-            // needed
-
-            SelectQuery clone = select.queryWithParameters(Collections.EMPTY_MAP, true);
-            clone.clearPrefetches();
-
-            // I guess this check is redundant, as custom attributes warrant data rows
-            if (!select.isFetchingCustomAttributes()) {
-                for (DbAttribute attribute : rootEntity.getDbEntity().getPrimaryKeys()) {
-                    clone.addCustomDbAttribute(attribute.getName());
-                }
-            }
-
-            query = clone;
-            resolvesFirstPage = false;
-        }
+        this.idWidth = metadata.getDbEntity().getPrimaryKeys().size();
 
         List<Object> elementsUnsynced = new ArrayList<Object>();
-        fillIn(query, elementsUnsynced, resolvesFirstPage);
+        fillIn(query, elementsUnsynced);
         this.elements = Collections.synchronizedList(elementsUnsynced);
     }
 
@@ -188,13 +164,13 @@
      * fully resolved. For the rest of the list, only ObjectIds are read.
      * 
      * @deprecated since 3.0 this method is not called and is deprecated in favor of
-     *             {@link #fillIn(Query, List, boolean)}, as this method performed
-     *             unneeded synchronization.
+     *             {@link #fillIn(Query, List)}, as this method performed unneeded
+     *             synchronization.
      * @since 1.0.6
      */
     protected void fillIn(Query query) {
         synchronized (elements) {
-            fillIn(query, elements, true);
+            fillIn(query, elements);
         }
     }
 
@@ -204,36 +180,17 @@
      * 
      * @since 3.0
      */
-    protected void fillIn(Query query, List elementsList, boolean resolvesFirstPage) {
-        QueryMetadata info = query.getMetaData(dataContext.getEntityResolver());
-        boolean fetchesDataRows = internalQuery.isFetchingDataRows();
+    protected void fillIn(final Query query, List elementsList) {
 
-        // start fresh
         elementsList.clear();
-        rowWidth = 0;
 
         try {
-            int lastResolved = 0;
             long t1 = System.currentTimeMillis();
             ResultIterator it = dataContext.performIteratedQuery(query);
             try {
 
-                rowWidth = it.getResultSetWidth();
-
-                // resolve first page if we can
-                if (resolvesFirstPage) {
-                    // read first page completely, the rest as ObjectIds
-                    for (int i = 0; i < pageSize && it.hasNextRow(); i++) {
-                        elementsList.add(it.nextRow());
-                        lastResolved++;
-                    }
-
-                    // defer DataRows -> Objects conversion till we are completely done.
-                }
-
-                // continue reading ids
                 while (it.hasNextRow()) {
-                    elementsList.add(it.nextId());
+                    elementsList.add(it.nextRow());
                 }
 
                 QueryLogger.logSelectCount(elementsList.size(), System
@@ -243,27 +200,13 @@
             finally {
                 it.close();
             }
-
-            // fill in the first page AFTER the iterator was closed, otherwise we may
-            // cause an (unobvious) deadlock due to connection pool exhaustion
-            if (!fetchesDataRows && lastResolved > 0) {
-                List objects = dataContext.objectsFromDataRows(
-                        info.getClassDescriptor(),
-                        elementsList.subList(0, lastResolved));
-
-                for (int i = 0; i < lastResolved; i++) {
-                    elementsList.set(i, objects.get(i));
-                }
-            }
         }
         catch (CayenneException e) {
             throw new CayenneRuntimeException("Error performing query.", Util
                     .unwindException(e));
         }
 
-        unfetchedObjects = (resolvesFirstPage)
-                ? elementsList.size() - pageSize
-                : elementsList.size();
+        unfetchedObjects = elementsList.size();
     }
 
     /**
@@ -836,8 +779,8 @@
 
                 Map<?, ?> id = (Map<?, ?>) objectInTheList;
                 Map<?, ?> map = (Map<?, ?>) object;
-                
-                if(id.size() != map.size()) {
+
+                if (id.size() != map.size()) {
                     return false;
                 }
 
@@ -860,7 +803,7 @@
         boolean replacesObject(Object object, Object objectInTheList) {
 
             Map<?, ?> id = (Map<?, ?>) objectInTheList;
-            if (id.size() == rowWidth) {
+            if (id.size() > idWidth) {
                 return false;
             }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultIterator.java Fri Dec 12 07:42:48 2008
@@ -20,11 +20,8 @@
 package org.apache.cayenne.access;
 
 import java.util.List;
-import java.util.Map;
 
 import org.apache.cayenne.CayenneException;
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.map.DbEntity;
 
 /**
  * Defines API of an iterator over the records returned as a result of SelectQuery
@@ -39,14 +36,6 @@
 public interface ResultIterator {
 
     /**
-     * Returns all unread data rows from ResultSet and closes this iterator if asked to do
-     * so.
-     * 
-     * @deprecated since 3.0 use {@link #allRows(boolean)}.
-     */
-    List<DataRow> dataRows(boolean close) throws CayenneException;
-
-    /**
      * Returns all yet unread rows from ResultSet and closes this iterator if asked to do
      * so.
      * 
@@ -61,13 +50,6 @@
     boolean hasNextRow() throws CayenneException;
 
     /**
-     * Returns the next result row as a Map.
-     * 
-     * @deprecated since 3.0 use {@link #nextRow()}.
-     */
-    Map<String, Object> nextDataRow() throws CayenneException;
-
-    /**
      * Returns the next result row that is, depending on the query, may be a scalar value,
      * a DataRow, or an Object[] array containing a mix of scalars and DataRows.
      * 
@@ -76,32 +58,6 @@
     Object nextRow() throws CayenneException;
 
     /**
-     * Returns a map of ObjectId values from the next result row. Primary key columns are
-     * determined from the provided DbEntity.
-     * 
-     * @since 1.1
-     * @deprecated since 3.0 in favor of {@link #nextId(DbEntity)}.
-     */
-    Map<String, Object> nextObjectId(DbEntity entity) throws CayenneException;
-
-    /**
-     * Reads and returns an id column or columns for the current row DbEntity. If an
-     * entity has a single column id, the return value is an Object matching the column
-     * type (e.g. java.lang.Long). If an entity has a compound PK, the return value is a
-     * DataRow.
-     * 
-     * @since 3.0
-     */
-    Object nextId() throws CayenneException;
-
-    /**
-     * Skips current data row instead of reading it.
-     * 
-     * @deprecated since 3.0 use {@link #skipRow()} instead.
-     */
-    void skipDataRow() throws CayenneException;
-
-    /**
      * @since 3.0
      */
     void skipRow() throws CayenneException;
@@ -112,19 +68,4 @@
      * database resources will not be released properly.
      */
     void close() throws CayenneException;
-
-    /**
-     * Returns the number of columns in the result row.
-     * 
-     * @since 1.0.6
-     * @deprecated since 3.0 in favor of {@link #getResultSetWidth()}.
-     */
-    int getDataRowWidth();
-
-    /**
-     * Returns a number of columns in the underlying ResultSet.
-     * 
-     * @since 3.0
-     */
-    int getResultSetWidth();
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java Fri Dec 12 07:42:48 2008
@@ -21,10 +21,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.cayenne.CayenneException;
-import org.apache.cayenne.map.DbEntity;
 
 /**
  * Decorates ResultIterator to close active transaction when the iterator is closed.
@@ -93,32 +91,11 @@
         return list;
     }
 
-    /**
-     * @deprecated since 3.0
-     */
-    public int getDataRowWidth() {
-        return result.getDataRowWidth();
-    }
-    
-    /**
-     * @since 3.0
-     */
-    public int getResultSetWidth() {
-        return result.getResultSetWidth();
-    }
-
     public boolean hasNextRow() throws CayenneException {
         return result.hasNextRow();
     }
 
     /**
-     * @deprecated since 3.0 in favor of {@link #nextRow()}.
-     */
-    public Map<String, Object> nextDataRow() throws CayenneException {
-        return result.nextDataRow();
-    }
-
-    /**
      * @since 3.0
      */
     public Object nextRow() throws CayenneException {
@@ -126,27 +103,6 @@
     }
 
     /**
-     * @deprecated since 3.0 in favor of {@link #nextId(DbEntity)}.
-     */
-    public Map nextObjectId(DbEntity entity) throws CayenneException {
-        return result.nextObjectId(entity);
-    }
-
-    /**
-     * @since 3.0
-     */
-    public Object nextId() throws CayenneException {
-        return result.nextId();
-    }
-
-    /**
-     * @deprecated since 3.0 in favor of {@link #skipRow()}.
-     */
-    public void skipDataRow() throws CayenneException {
-        result.skipDataRow();
-    }
-
-    /**
      * @since 3.0
      */
     public void skipRow() throws CayenneException {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/DistinctResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/DistinctResultIterator.java?rev=726053&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/DistinctResultIterator.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/DistinctResultIterator.java Fri Dec 12 07:42:48 2008
@@ -0,0 +1,171 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access.jdbc;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cayenne.CayenneException;
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.access.ResultIterator;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+
+/**
+ * A ResultIterator that does in-memory filtering of rows to return only distinct rows.
+ * Distinct comparison is done by comparing ObjectIds created from each row. Internally
+ * DistinctResultIterator wraps another ResultIterator that provides the actual rows.
+ * 
+ * @since 3.0
+ */
+public class DistinctResultIterator implements ResultIterator {
+
+    protected ResultIterator wrappedIterator;
+    protected Set<Map<String, Object>> fetchedIds;
+    protected Object nextDataRow;
+    protected DbEntity defaultEntity;
+    protected boolean compareFullRows;
+
+    /**
+     * Creates new DistinctResultIterator wrapping another ResultIterator.
+     * 
+     * @param wrappedIterator
+     * @param defaultEntity an entity needed to build ObjectIds for distinct comparison.
+     */
+    public DistinctResultIterator(ResultIterator wrappedIterator, DbEntity defaultEntity,
+            boolean compareFullRows) throws CayenneException {
+        if (wrappedIterator == null) {
+            throw new CayenneException("Null wrapped iterator.");
+        }
+
+        if (defaultEntity == null) {
+            throw new CayenneException("Null defaultEntity.");
+        }
+
+        this.wrappedIterator = wrappedIterator;
+        this.defaultEntity = defaultEntity;
+        this.fetchedIds = new HashSet<Map<String, Object>>();
+        this.compareFullRows = compareFullRows;
+
+        checkNextRow();
+    }
+
+    /**
+     * CLoses underlying ResultIterator.
+     */
+    public void close() throws CayenneException {
+        wrappedIterator.close();
+    }
+
+    /**
+     * @since 3.0
+     */
+    public List allRows(boolean close) throws CayenneException {
+        List<Object> list = new ArrayList<Object>();
+
+        try {
+            while (this.hasNextRow()) {
+                list.add(nextRow());
+            }
+            return list;
+        }
+        finally {
+            if (close) {
+                this.close();
+            }
+        }
+    }
+
+    public boolean hasNextRow() throws CayenneException {
+        return nextDataRow != null;
+    }
+
+    public Object nextRow() throws CayenneException {
+        if (!hasNextRow()) {
+            throw new CayenneException(
+                    "An attempt to read uninitialized row or past the end of the iterator.");
+        }
+
+        Object row = nextDataRow;
+        checkNextRow();
+        return row;
+    }
+
+    /**
+     * @since 3.0
+     */
+    public void skipRow() throws CayenneException {
+        if (!hasNextRow()) {
+            throw new CayenneException(
+                    "An attempt to read uninitialized row or past the end of the iterator.");
+        }
+
+        checkNextRow();
+    }
+
+    void checkNextRow() throws CayenneException {
+
+        if (this.compareFullRows) {
+            checkNextUniqueRow();
+        }
+        else {
+            checkNextRowWithUniqueId();
+        }
+    }
+
+    void checkNextUniqueRow() throws CayenneException {
+
+        nextDataRow = null;
+        while (wrappedIterator.hasNextRow()) {
+            DataRow next = (DataRow) wrappedIterator.nextRow();
+
+            if (fetchedIds.add(next)) {
+                this.nextDataRow = next;
+                break;
+            }
+        }
+    }
+
+    void checkNextRowWithUniqueId() throws CayenneException {
+
+        nextDataRow = null;
+        while (wrappedIterator.hasNextRow()) {
+            DataRow next = (DataRow) wrappedIterator.nextRow();
+
+            // create id map...
+            // TODO: this can be optimized by creating an array with id keys
+            // to avoid iterating over default entity attributes...
+
+            Map<String, Object> id = new HashMap<String, Object>();
+            for (final DbAttribute pk : defaultEntity.getPrimaryKeys()) {
+                id.put(pk.getName(), next.get(pk.getName()));
+            }
+
+            if (fetchedIds.add(id)) {
+                this.nextDataRow = next;
+                break;
+            }
+        }
+    }
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java Fri Dec 12 07:42:48 2008
@@ -25,13 +25,10 @@
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.ResultIterator;
-import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.query.EntityResultSegment;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.SQLResultSetMetadata;
@@ -58,9 +55,7 @@
 
     protected boolean nextRow;
 
-    private DataRowPostProcessor postProcessor;
     private RowReader<?> rowReader;
-    private RowReader<Object> idRowReader;
 
     /**
      * Creates new JDBCResultIterator that reads from provided ResultSet.
@@ -148,7 +143,11 @@
     private RowReader<?> createFullRowReader(
             RowDescriptor descriptor,
             QueryMetadata queryMetadata) {
-        if (queryMetadata.getClassDescriptor() != null
+
+        if (queryMetadata.getPageSize() > 0) {
+            return new IdRowReader(descriptor, queryMetadata);
+        }
+        else if (queryMetadata.getClassDescriptor() != null
                 && queryMetadata.getClassDescriptor().getEntityInheritanceTree() != null) {
             return new InheritanceAwareRowReader(descriptor, queryMetadata);
         }
@@ -158,15 +157,6 @@
     }
 
     /**
-     * Returns all unread data rows from ResultSet, closing this iterator if needed.
-     * 
-     * @deprecated since 3.0
-     */
-    public List<DataRow> dataRows(boolean close) throws CayenneException {
-        return allRows(close);
-    }
-
-    /**
      * @since 3.0
      */
     public List allRows(boolean close) throws CayenneException {
@@ -195,15 +185,6 @@
     }
 
     /**
-     * Returns the next result row as a Map.
-     * 
-     * @deprecated since 3.0
-     */
-    public Map<String, Object> nextDataRow() throws CayenneException {
-        return (DataRow) nextRow();
-    }
-
-    /**
      * @since 3.0
      */
     public Object nextRow() throws CayenneException {
@@ -218,64 +199,6 @@
     }
 
     /**
-     * Returns a map of ObjectId values from the next result row. Primary key columns are
-     * determined from the provided DbEntity.
-     * 
-     * @deprecated since 3.0 in favor of {@link #nextId(DbEntity)}.
-     */
-    public Map<String, Object> nextObjectId(DbEntity entity) throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        // index id
-        if (idRowReader == null) {
-            this.idRowReader = new IdRowReader(rowDescriptor, queryMetadata);
-            idRowReader.setPostProcessor(postProcessor);
-        }
-
-        // read ...
-        // TODO: note a mismatch with 1.1 API - ID positions are preset and are
-        // not affected by the entity specified (think of deprecating/replacing this)
-        Map<String, Object> row = readIdRow();
-
-        // rewind
-        checkNextRow();
-
-        return row;
-    }
-
-    /**
-     * @since 3.0
-     */
-    public Object nextId() throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        // index id
-        if (idRowReader == null) {
-            this.idRowReader = new IdRowReader(rowDescriptor, queryMetadata);
-            idRowReader.setPostProcessor(postProcessor);
-        }
-
-        Object id = idRowReader.readRow(resultSet);
-
-        // rewind
-        checkNextRow();
-        return id;
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    public void skipDataRow() throws CayenneException {
-        skipRow();
-    }
-
-    /**
      * @since 3.0
      */
     public void skipRow() throws CayenneException {
@@ -338,22 +261,6 @@
     }
 
     /**
-     * Returns the number of columns in the result row.
-     * 
-     * @deprecated since 3.0
-     */
-    public int getDataRowWidth() {
-        return getResultSetWidth();
-    }
-
-    /**
-     * @since 3.0
-     */
-    public int getResultSetWidth() {
-        return rowDescriptor.getWidth();
-    }
-
-    /**
      * Moves internal ResultSet cursor position down one row. Checks if the next row is
      * available.
      */
@@ -370,41 +277,6 @@
     }
 
     /**
-     * Reads a row from the internal ResultSet at the current cursor position.
-     * 
-     * @deprecated since 3.0. Internal rowReader is used to read individual rows.
-     */
-    protected Map<String, Object> readDataRow() throws CayenneException {
-        return (DataRow) rowReader.readRow(resultSet);
-    }
-
-    /**
-     * Reads a row from the internal ResultSet at the current cursor position, processing
-     * only columns that are part of the ObjectId of a target class.
-     * 
-     * @deprecated since 3.0 as the calling method is deprecated
-     */
-    protected Map<String, Object> readIdRow() throws CayenneException {
-        Object value = idRowReader.readRow(resultSet);
-
-        if (value instanceof Map) {
-            return (Map<String, Object>) value;
-        }
-
-        // wrap into a map...
-
-        String pkName = queryMetadata
-                .getDbEntity()
-                .getPrimaryKeys()
-                .iterator()
-                .next()
-                .getName();
-        DataRow dataRow = new DataRow(2);
-        dataRow.put(pkName, value);
-        return dataRow;
-    }
-
-    /**
      * Returns <code>true</code> if this iterator is responsible for closing its
      * connection, otherwise a user of the iterator must close the connection after
      * closing the iterator.
@@ -426,14 +298,9 @@
 
     // TODO: andrus 11/27/2008 refactor the postprocessor hack into a special row reader.
     void setPostProcessor(DataRowPostProcessor postProcessor) {
-        this.postProcessor = postProcessor;
 
         if (rowReader != null) {
             rowReader.setPostProcessor(postProcessor);
         }
-
-        if (idRowReader != null) {
-            idRowReader.setPostProcessor(postProcessor);
-        }
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/LimitResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/LimitResultIterator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/LimitResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/LimitResultIterator.java Fri Dec 12 07:42:48 2008
@@ -23,9 +23,7 @@
 import java.util.Map;
 
 import org.apache.cayenne.CayenneException;
-import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.ResultIterator;
-import org.apache.cayenne.map.DbEntity;
 
 /**
  * @since 3.0
@@ -77,13 +75,6 @@
     }
 
     /**
-     * @deprecated since 3.0
-     */
-    public List dataRows(boolean close) throws CayenneException {
-        return allRows(close);
-    }
-
-    /**
      * @since 3.0
      */
     public List allRows(boolean close) throws CayenneException {
@@ -104,32 +95,11 @@
         return list;
     }
 
-    /**
-     * @deprecated since 3.0
-     */
-    public int getDataRowWidth() {
-        return wrappedIterator.getDataRowWidth();
-    }
-    
-    /**
-     * @since 3.0
-     */
-    public int getResultSetWidth() {
-        return wrappedIterator.getResultSetWidth();
-    }
-
     public boolean hasNextRow() throws CayenneException {
         return nextRow;
     }
 
     /**
-     * @deprecated since 3.0
-     */
-    public Map<String, Object> nextDataRow() throws CayenneException {
-        return (DataRow) nextRow();
-    }
-
-    /**
      * @since 3.0
      */
     public Object nextRow() throws CayenneException {
@@ -143,69 +113,10 @@
         return row;
     }
 
-    public Object nextId() throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        Object id = readId();
-        checkNextId();
-        return id;
-
-    }
-
-    /**
-     * @deprecated since 3.0 in favor of {@link #nextId(DbEntity)}.
-     */
-    public Map<String, Object> nextObjectId(DbEntity entity) throws CayenneException {
-
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        checkNextObjectId(entity);
-        return nextDataObjectIds;
-    }
-
-    /**
-     * @deprecated since 3.0 in favor of {@link #skipRow()}.
-     */
-    public void skipDataRow() throws CayenneException {
-        wrappedIterator.skipDataRow();
-    }
-
     /**
      * @since 3.0
      */
     public void skipRow() throws CayenneException {
         wrappedIterator.skipRow();
     }
-
-    void checkNextId() throws CayenneException {
-        nextRow = false;
-        if (wrappedIterator.hasNextRow()) {
-            nextRow = true;
-        }
-    }
-
-    private Object readId() throws CayenneException {
-        Object next = wrappedIterator.nextId();
-        return next;
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    void checkNextObjectId(DbEntity entity) throws CayenneException {
-
-        nextRow = false;
-        nextDataObjectIds = null;
-        if (wrappedIterator.hasNextRow()) {
-            nextRow = true;
-            Map<String, Object> next = wrappedIterator.nextObjectId(entity);
-            nextDataObjectIds = next;
-        }
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java Fri Dec 12 07:42:48 2008
@@ -30,7 +30,6 @@
 import org.apache.cayenne.access.QueryLogger;
 import org.apache.cayenne.access.ResultIterator;
 import org.apache.cayenne.access.trans.SelectTranslator;
-import org.apache.cayenne.access.util.DistinctResultIterator;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.query.PrefetchProcessor;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java Fri Dec 12 07:42:48 2008
@@ -256,6 +256,9 @@
         if (query.isFetchingCustomAttributes()) {
             appendCustomColumns(columns, query);
         }
+        else if (getQueryMetadata().getPageSize() > 0) {
+            appendIdColumns(columns, query);
+        }
         else {
             appendQueryColumns(columns, query);
         }
@@ -493,6 +496,27 @@
         return columns;
     }
 
+    List<ColumnDescriptor> appendIdColumns(
+            final List<ColumnDescriptor> columns,
+            SelectQuery query) {
+
+        Set<DbAttribute> skipSet = new HashSet<DbAttribute>();
+
+        ClassDescriptor descriptor = queryMetadata.getClassDescriptor();
+        ObjEntity oe = descriptor.getEntity();
+        DbEntity dbEntity = oe.getDbEntity();
+        for (ObjAttribute attribute : oe.getPrimaryKeys()) {
+
+            // synthetic objattributes can't reliably lookup their DbAttribute, so do
+            // it manually..
+            DbAttribute dbAttribute = (DbAttribute) dbEntity.getAttribute(attribute
+                    .getDbAttributeName());
+            appendColumn(columns, attribute, dbAttribute, skipSet, null);
+        }
+
+        return columns;
+    }
+
     /**
      * Appends custom columns from SelectQuery to the provided list.
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/util/DistinctResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/util/DistinctResultIterator.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/util/DistinctResultIterator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/util/DistinctResultIterator.java Fri Dec 12 07:42:48 2008
@@ -19,279 +19,19 @@
 
 package org.apache.cayenne.access.util;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.cayenne.CayenneException;
-import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.ResultIterator;
-import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 
 /**
- * A ResultIterator that does in-memory filtering of rows to return only distinct rows.
- * Distinct comparison is done by comparing ObjectIds created from each row. Internally
- * DistinctResultIterator wraps another ResultIterator that provides the actual rows. The
- * current limitation is that once switched to reading ids instead of rows (i.e. when
- * "nextObjectId()" is called for the first time), it can't be used to read data rows
- * again. This is pretty sensible for most things in Cayenne.
- * 
+ * @deprecated since 3.0 moved to access.jdbc package.
  * @since 1.2
  */
-public class DistinctResultIterator implements ResultIterator {
-
-    protected ResultIterator wrappedIterator;
-    protected Set<Map<String, Object>> fetchedIds;
-    protected Object nextDataRow;
-    protected DbEntity defaultEntity;
-    protected boolean compareFullRows;
+public class DistinctResultIterator extends
+        org.apache.cayenne.access.jdbc.DistinctResultIterator {
 
-    protected boolean readingIds;
-
-    /**
-     * Creates new DistinctResultIterator wrapping another ResultIterator.
-     * 
-     * @param wrappedIterator
-     * @param defaultEntity an entity needed to build ObjectIds for distinct comparison.
-     */
     public DistinctResultIterator(ResultIterator wrappedIterator, DbEntity defaultEntity,
             boolean compareFullRows) throws CayenneException {
-        if (wrappedIterator == null) {
-            throw new CayenneException("Null wrapped iterator.");
-        }
-
-        if (defaultEntity == null) {
-            throw new CayenneException("Null defaultEntity.");
-        }
-
-        this.wrappedIterator = wrappedIterator;
-        this.defaultEntity = defaultEntity;
-        this.fetchedIds = new HashSet<Map<String, Object>>();
-        this.compareFullRows = compareFullRows;
-
-        checkNextRow();
-    }
-
-    /**
-     * CLoses underlying ResultIterator.
-     */
-    public void close() throws CayenneException {
-        wrappedIterator.close();
-    }
-
-    /**
-     * Returns all data rows.
-     * 
-     * @deprecated since 3.0
-     */
-    public List dataRows(boolean close) throws CayenneException {
-        return allRows(close);
-    }
-
-    /**
-     * @since 3.0
-     */
-    public List allRows(boolean close) throws CayenneException {
-        List<Object> list = new ArrayList<Object>();
-
-        try {
-            while (this.hasNextRow()) {
-                list.add(nextRow());
-            }
-            return list;
-        }
-        finally {
-            if (close) {
-                this.close();
-            }
-        }
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    public int getDataRowWidth() {
-        return wrappedIterator.getDataRowWidth();
-    }
-    
-    public int getResultSetWidth() {
-        return wrappedIterator.getResultSetWidth();
-    }
-
-    public boolean hasNextRow() throws CayenneException {
-        return nextDataRow != null;
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    public Map nextDataRow() throws CayenneException {
-        return (DataRow) nextRow();
-    }
-
-    public Object nextRow() throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        Object row = nextDataRow;
-        checkNextRow();
-        return row;
-    }
-
-    /**
-     * Returns a Map for the next ObjectId. After calling this method, calls to
-     * "nextDataRow()" will result in exceptions.
-     * 
-     * @deprecated since 3.0 in favor of {@link #nextId(DbEntity)}.
-     */
-    public Map nextObjectId(DbEntity entity) throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        DataRow row = (DataRow) nextDataRow;
-
-        // if we were previously reading full rows, we need to strip extra keys...
-        if (!readingIds) {
-            Iterator<Map.Entry<String, Object>> it = row.entrySet().iterator();
-            while (it.hasNext()) {
-                Map.Entry<String, Object> entry = it.next();
-                String name = entry.getKey();
-                DbAttribute attribute = (DbAttribute) entity.getAttribute(name);
-                if (attribute == null || !attribute.isPrimaryKey()) {
-                    it.remove();
-                }
-            }
-        }
-
-        checkNextId(entity);
-        return row;
-    }
-
-    /**
-     * @since 3.0
-     */
-    public Object nextId() throws CayenneException {
-
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        if (!(nextDataRow instanceof DataRow)) {
-            throw new IllegalStateException(
-                    "A query is not fetching DataRows. Can't call 'nextId'");
-        }
-
-        DataRow row = (DataRow) nextDataRow;
-
-        checkNextId(defaultEntity);
-
-        // TODO: andrus 3/6/2008: not very efficient ... a better algorithm would've
-        // relied on wrapped iterator 'nextId' method.
-        return row.get(defaultEntity.getPrimaryKeys().iterator().next().getName());
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    public void skipDataRow() throws CayenneException {
-        skipRow();
-    }
-
-    /**
-     * @since 3.0
-     */
-    public void skipRow() throws CayenneException {
-        if (!hasNextRow()) {
-            throw new CayenneException(
-                    "An attempt to read uninitialized row or past the end of the iterator.");
-        }
-
-        if (readingIds) {
-            checkNextId(defaultEntity);
-        }
-        else {
-            checkNextRow();
-        }
-    }
-
-    void checkNextRow() throws CayenneException {
-        if (readingIds) {
-            throw new CayenneException(
-                    "Can't go back from reading ObjectIds to reading rows.");
-        }
-
-        if (this.compareFullRows) {
-            checkNextUniqueRow();
-        }
-        else {
-            checkNextRowWithUniqueId();
-        }
-    }
-
-    void checkNextUniqueRow() throws CayenneException {
-
-        nextDataRow = null;
-        while (wrappedIterator.hasNextRow()) {
-            DataRow next = (DataRow) wrappedIterator.nextRow();
-
-            if (fetchedIds.add(next)) {
-                this.nextDataRow = next;
-                break;
-            }
-        }
-    }
-
-    void checkNextRowWithUniqueId() throws CayenneException {
-
-        nextDataRow = null;
-        while (wrappedIterator.hasNextRow()) {
-            DataRow next = (DataRow) wrappedIterator.nextRow();
-
-            // create id map...
-            // TODO: this can be optimized by creating an array with id keys
-            // to avoid iterating over default entity attributes...
-
-            Map<String, Object> id = new HashMap<String, Object>();
-            for (final DbAttribute pk : defaultEntity.getPrimaryKeys()) {
-                id.put(pk.getName(), next.get(pk.getName()));
-            }
-
-            if (fetchedIds.add(id)) {
-                this.nextDataRow = next;
-                break;
-            }
-        }
-    }
-
-    /**
-     * @deprecated since 3.0
-     */
-    void checkNextId(DbEntity entity) throws CayenneException {
-        if (entity == null) {
-            throw new CayenneException("Null DbEntity, can't create id.");
-        }
-
-        this.readingIds = true;
-        this.nextDataRow = null;
-
-        while (wrappedIterator.hasNextRow()) {
-            Map<String, Object> next = wrappedIterator.nextObjectId(entity);
-
-            // if we are reading ids, we ignore "compareFullRows" setting
-            if (fetchedIds.add(next)) {
-                this.nextDataRow = next;
-                break;
-            }
-        }
+        super(wrappedIterator, defaultEntity, compareFullRows);
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SelectQuery.java Fri Dec 12 07:42:48 2008
@@ -39,7 +39,6 @@
  * A query that selects persistent objects of a certain type or "raw data" (aka DataRows).
  * Supports expression qualifier, multiple orderings and a number of other parameters that
  * serve as runtime hints to Cayenne on how to optimize the fetch and result processing.
- * 
  */
 public class SelectQuery extends QualifiedQuery implements ParameterizedQuery,
         XMLSerializable {
@@ -165,7 +164,12 @@
     @Override
     public void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery) {
         super.route(router, resolver, substitutedQuery);
-        routePrefetches(router, resolver);
+
+        // suppress prefetches for paginated queries.. instead prefetches will be resolved
+        // per row...
+        if (metaData.getPageSize() <= 0) {
+            routePrefetches(router, resolver);
+        }
     }
 
     /**
@@ -396,8 +400,8 @@
     /**
      * Adds one or more aliases for the qualifier expression path. Aliases serve to
      * instruct Cayenne to generate separate sets of joins for overlapping paths, that
-     * maybe needed for complex conditions. An example of an <i>implicit<i> splits is
-     * this method: {@link ExpressionFactory#matchAllExp(String, Object...)}.
+     * maybe needed for complex conditions. An example of an <i>implicit<i> splits is this
+     * method: {@link ExpressionFactory#matchAllExp(String, Object...)}.
      * 
      * @since 3.0
      */
@@ -438,8 +442,8 @@
 
     /**
      * Returns <code>true</code> if there is at least one custom query attribute
-     * specified, otherwise returns <code>false</code> for the case when the query
-     * results will contain only the root entity attributes.
+     * specified, otherwise returns <code>false</code> for the case when the query results
+     * will contain only the root entity attributes.
      * <p>
      * Note that queries that are fetching custom attributes always return data rows
      * instead of DataObjects.
@@ -499,8 +503,8 @@
     }
 
     /**
-     * Sets query result type. If <code>flag</code> parameter is <code>true</code>,
-     * then results will be in the form of data rows.
+     * Sets query result type. If <code>flag</code> parameter is <code>true</code>, then
+     * results will be in the form of data rows.
      * <p>
      * <i>Note that if <code>isFetchingCustAttributes()</code> returns <code>true</code>,
      * this setting has no effect, and data rows are always fetched. </i>
@@ -515,8 +519,8 @@
      * 
      * @since 1.1
      * @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();
@@ -525,8 +529,8 @@
     /**
      * @since 1.1
      * @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
@@ -576,7 +580,7 @@
     public void setCacheGroups(String... cacheGroups) {
         this.metaData.setCacheGroups(cacheGroups);
     }
-    
+
     /**
      * Returns the fetchOffset.
      * 
@@ -585,7 +589,7 @@
     public int getFetchOffset() {
         return metaData.getFetchOffset();
     }
-    
+
     /**
      * Returns the fetchLimit.
      */
@@ -599,7 +603,7 @@
     public void setFetchLimit(int fetchLimit) {
         this.metaData.setFetchLimit(fetchLimit);
     }
-    
+
     /**
      * @since 3.0
      */

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java?rev=726053&r1=726052&r2=726053&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java Fri Dec 12 07:42:48 2008
@@ -58,17 +58,15 @@
     }
 
     public void testGet1() throws Exception {
-        assertEquals(3, list.rowWidth);
-        assertTrue(list.elements.get(0) instanceof Map);
-        assertEquals(list.rowWidth, ((Map) list.elements.get(0)).size());
-
+        assertEquals(1, list.idWidth);
+        assertFalse(list.elements.get(0) instanceof Map);
         assertTrue(list.elements.get(19) instanceof Long);
 
         Object a = list.get(19);
 
         assertNotNull(a);
         assertTrue(a instanceof Map);
-        assertEquals(list.rowWidth, ((Map) a).size());
+        assertEquals(3, ((Map) a).size());
         assertEquals("artist20", ((Map) a).get("ARTIST_NAME"));
     }
 
@@ -94,6 +92,9 @@
 
     public void testIndexOf2() throws Exception {
         DataContext parallelContext = createDataContext();
+        
+        // resolve first page
+        list.get(0);
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist2");
         SelectQuery query = new SelectQuery(Artist.class, qual);
@@ -111,6 +112,9 @@
 
     public void testLastIndexOf1() throws Exception {
         DataContext parallelContext = createDataContext();
+       
+        // resolve first page
+        list.get(0);
 
         Expression qual = ExpressionFactory.matchExp("artistName", "artist3");
         SelectQuery query = new SelectQuery(Artist.class, qual);
@@ -144,7 +148,7 @@
     }
 
     public void testIterator() throws Exception {
-        assertEquals(3, list.rowWidth);
+        assertEquals(1, list.idWidth);
 
         Iterator it = list.iterator();
         int counter = 0;
@@ -154,7 +158,7 @@
             assertTrue(
                     "Unexpected object class: " + obj.getClass().getName(),
                     obj instanceof Map);
-            assertEquals(list.rowWidth, ((Map) obj).size());
+            assertEquals(3, ((Map) obj).size());
 
             // iterator must be resolved page by page
             int expectedResolved = list.pageIndex(counter)



Mime
View raw message