cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1576776 - in /cayenne/main/trunk/cayenne-server/src: main/java/org/apache/cayenne/access/jdbc/ test/java/org/apache/cayenne/access/jdbc/
Date Wed, 12 Mar 2014 15:13:30 GMT
Author: aadamchik
Date: Wed Mar 12 15:13:29 2014
New Revision: 1576776

URL: http://svn.apache.org/r1576776
Log:
CAY-1907 RowReaderFactory

hiding DataRowPostProcessor in the reader factory

Modified:
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseSQLAction.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/CompoundRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DataRowPostProcessor.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DefaultRowReaderFactory.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/EntityRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/FullRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareEntityRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReaderFactory.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/ScalarRowReader.java
    cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
    cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseRowReader.java
Wed Mar 12 15:13:29 2014
@@ -35,12 +35,13 @@ abstract class BaseRowReader<T> implemen
     DataRowPostProcessor postProcessor;
     String entityName;
 
-    BaseRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata) {
+    BaseRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata, DataRowPostProcessor
postProcessor) {
         ObjEntity rootObjEntity = queryMetadata.getObjEntity();
         if (rootObjEntity != null) {
             this.entityName = rootObjEntity.getName();
         }
 
+        this.postProcessor = postProcessor;
         this.converters = descriptor.getConverters();
 
         ColumnDescriptor[] columns = descriptor.getColumns();
@@ -57,9 +58,4 @@ abstract class BaseRowReader<T> implemen
     @Override
     public abstract T readRow(ResultSet resultSet);
 
-    @Override
-    public void setPostProcessor(DataRowPostProcessor postProcessor) {
-        this.postProcessor = postProcessor;
-    }
-
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseSQLAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseSQLAction.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseSQLAction.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BaseSQLAction.java
Wed Mar 12 15:13:29 2014
@@ -69,7 +69,7 @@ public abstract class BaseSQLAction impl
 
         QueryMetadata metadata = query.getMetaData(getEntityResolver());
 
-        RowReader<?> rowReader = rowReaderFactory.createRowReader(descriptor, metadata);
+        RowReader<?> rowReader = rowReaderFactory.createRowReader(descriptor, metadata,
null);
 
         JDBCResultIterator resultReader = new JDBCResultIterator(null, resultSet, rowReader);
 

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
Wed Mar 12 15:13:29 2014
@@ -286,7 +286,7 @@ public class BatchAction extends BaseSQL
         }
 
         RowReader<?> rowReader = rowReaderFactory.createRowReader(keyRowDescriptor,
-                query.getMetaData(getEntityResolver()));
+                query.getMetaData(getEntityResolver()), null);
         ResultIterator iterator = new JDBCResultIterator(null, keysRS, rowReader);
 
         observer.nextGeneratedRows(query, iterator);

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/CompoundRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/CompoundRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/CompoundRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/CompoundRowReader.java
Wed Mar 12 15:13:29 2014
@@ -49,11 +49,4 @@ class CompoundRowReader implements RowRe
 
         return row;
     }
-
-    @Override
-    public void setPostProcessor(DataRowPostProcessor postProcessor) {
-        for (RowReader<?> reader : readers) {
-            reader.setPostProcessor(postProcessor);
-        }
-    }
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DataRowPostProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DataRowPostProcessor.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DataRowPostProcessor.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DataRowPostProcessor.java
Wed Mar 12 15:13:29 2014
@@ -108,8 +108,7 @@ class DataRowPostProcessor {
         return new DataRowPostProcessor(rootDescriptor, columnOverrides);
     }
 
-    private DataRowPostProcessor(ClassDescriptor classDescriptor,
-            Map<String, Collection<ColumnOverride>> columnOverrides) {
+    DataRowPostProcessor(ClassDescriptor classDescriptor, Map<String, Collection<ColumnOverride>>
columnOverrides) {
 
         if (classDescriptor != null && classDescriptor.hasSubclasses()) {
             this.inheritanceTree = classDescriptor.getEntityInheritanceTree();

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DefaultRowReaderFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DefaultRowReaderFactory.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DefaultRowReaderFactory.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/DefaultRowReaderFactory.java
Wed Mar 12 15:13:29 2014
@@ -18,12 +18,24 @@
  ****************************************************************/
 package org.apache.cayenne.access.jdbc;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.jdbc.DataRowPostProcessor.ColumnOverride;
+import org.apache.cayenne.access.trans.SelectTranslator;
+import org.apache.cayenne.access.types.ExtendedType;
+import org.apache.cayenne.dba.TypesMapping;
+import org.apache.cayenne.map.Entity;
+import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.query.EntityResultSegment;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.ScalarResultSegment;
+import org.apache.cayenne.reflect.ClassDescriptor;
 
 /**
  * @since 3.2
@@ -31,11 +43,14 @@ import org.apache.cayenne.query.ScalarRe
 public class DefaultRowReaderFactory implements RowReaderFactory {
 
     @Override
-    public RowReader<?> createRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata)
{
+    public RowReader<?> createRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata,
+            SelectTranslator translator) {
+
+        PostprocessorFactory postProcessorFactory = new PostprocessorFactory(translator,
queryMetadata);
 
         List<Object> rsMapping = queryMetadata.getResultSetMapping();
         if (rsMapping == null) {
-            return createFullRowReader(descriptor, queryMetadata);
+            return createFullRowReader(descriptor, queryMetadata, postProcessorFactory);
         }
 
         int resultWidth = rsMapping.size();
@@ -46,7 +61,8 @@ public class DefaultRowReaderFactory imp
             Object segment = rsMapping.get(0);
 
             if (segment instanceof EntityResultSegment) {
-                return createEntityRowReader(descriptor, queryMetadata, (EntityResultSegment)
segment);
+                return createEntityRowReader(descriptor, queryMetadata, (EntityResultSegment)
segment,
+                        postProcessorFactory);
             } else {
                 return new ScalarRowReader<Object>(descriptor, (ScalarResultSegment)
segment);
             }
@@ -57,8 +73,10 @@ public class DefaultRowReaderFactory imp
                 Object segment = rsMapping.get(i);
 
                 if (segment instanceof EntityResultSegment) {
-                    reader.addRowReader(i,
-                            createEntityRowReader(descriptor, queryMetadata, (EntityResultSegment)
segment));
+                    reader.addRowReader(
+                            i,
+                            createEntityRowReader(descriptor, queryMetadata, (EntityResultSegment)
segment,
+                                    postProcessorFactory));
                 } else {
                     reader.addRowReader(i, new ScalarRowReader<Object>(descriptor,
(ScalarResultSegment) segment));
                 }
@@ -69,25 +87,117 @@ public class DefaultRowReaderFactory imp
     }
 
     private RowReader<?> createEntityRowReader(RowDescriptor descriptor, QueryMetadata
queryMetadata,
-            EntityResultSegment resultMetadata) {
+            EntityResultSegment resultMetadata, PostprocessorFactory postProcessorFactory)
{
 
         if (queryMetadata.getPageSize() > 0) {
-            return new IdRowReader<Object>(descriptor, queryMetadata);
+            return new IdRowReader<Object>(descriptor, queryMetadata, postProcessorFactory.get());
         } else if (resultMetadata.getClassDescriptor() != null && resultMetadata.getClassDescriptor().hasSubclasses())
{
-            return new InheritanceAwareEntityRowReader(descriptor, resultMetadata);
+            return new InheritanceAwareEntityRowReader(descriptor, resultMetadata, postProcessorFactory.get());
         } else {
-            return new EntityRowReader(descriptor, resultMetadata);
+            return new EntityRowReader(descriptor, resultMetadata, postProcessorFactory.get());
         }
     }
 
-    private RowReader<?> createFullRowReader(RowDescriptor descriptor, QueryMetadata
queryMetadata) {
+    private RowReader<?> createFullRowReader(RowDescriptor descriptor, QueryMetadata
queryMetadata,
+            PostprocessorFactory postProcessorFactory) {
 
         if (queryMetadata.getPageSize() > 0) {
-            return new IdRowReader<Object>(descriptor, queryMetadata);
+            return new IdRowReader<Object>(descriptor, queryMetadata, postProcessorFactory.get());
         } else if (queryMetadata.getClassDescriptor() != null && queryMetadata.getClassDescriptor().hasSubclasses())
{
-            return new InheritanceAwareRowReader(descriptor, queryMetadata);
+            return new InheritanceAwareRowReader(descriptor, queryMetadata, postProcessorFactory.get());
         } else {
-            return new FullRowReader(descriptor, queryMetadata);
+            return new FullRowReader(descriptor, queryMetadata, postProcessorFactory.get());
+        }
+    }
+
+    private class PostprocessorFactory {
+
+        private QueryMetadata queryMetadata;
+        private SelectTranslator translator;
+        private boolean created;
+        private DataRowPostProcessor postProcessor;
+
+        PostprocessorFactory(SelectTranslator translator, QueryMetadata queryMetadata) {
+            this.translator = translator;
+            this.queryMetadata = queryMetadata;
+        }
+
+        DataRowPostProcessor get() {
+
+            if (!created) {
+                postProcessor = create();
+                created = true;
+            }
+
+            return postProcessor;
+        }
+
+        private DataRowPostProcessor create() {
+
+            // TODO: ugly... ideally we should care not about the translator...
+
+            if (translator == null) {
+                return null;
+            }
+
+            Map<ObjAttribute, ColumnDescriptor> attributeOverrides = translator.getAttributeOverrides();
+            if (attributeOverrides.isEmpty()) {
+                return null;
+            }
+
+            ColumnDescriptor[] columns = translator.getResultColumns();
+
+            Map<String, Collection<ColumnOverride>> columnOverrides = new HashMap<String,
Collection<ColumnOverride>>(2);
+
+            for (Entry<ObjAttribute, ColumnDescriptor> entry : attributeOverrides.entrySet())
{
+
+                ObjAttribute attribute = entry.getKey();
+                Entity entity = attribute.getEntity();
+
+                String key = null;
+                int jdbcType = TypesMapping.NOT_DEFINED;
+                int index = -1;
+                for (int i = 0; i < columns.length; i++) {
+                    if (columns[i] == entry.getValue()) {
+
+                        // if attribute type is the same as column, there is no
+                        // conflict
+                        if (!attribute.getType().equals(columns[i].getJavaClass())) {
+                            // note that JDBC index is "1" based
+                            index = i + 1;
+                            jdbcType = columns[i].getJdbcType();
+                            key = columns[i].getDataRowKey();
+                        }
+
+                        break;
+                    }
+                }
+
+                if (index < 1) {
+                    continue;
+                }
+
+                ExtendedType converter = translator.getAdapter().getExtendedTypes()
+                        .getRegisteredType(attribute.getType());
+
+                Collection<ColumnOverride> overrides = columnOverrides.get(entity.getName());
+
+                if (overrides == null) {
+                    overrides = new ArrayList<ColumnOverride>(3);
+                    columnOverrides.put(entity.getName(), overrides);
+                }
+
+                overrides.add(new ColumnOverride(index, key, converter, jdbcType));
+            }
+
+            // inject null post-processor
+            if (columnOverrides.isEmpty()) {
+                return null;
+            }
+
+            ClassDescriptor rootDescriptor = queryMetadata.getClassDescriptor();
+
+            return new DataRowPostProcessor(rootDescriptor, columnOverrides);
         }
     }
 

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/EntityRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/EntityRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/EntityRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/EntityRowReader.java
Wed Mar 12 15:13:29 2014
@@ -42,7 +42,9 @@ class EntityRowReader implements RowRead
 
     DataRowPostProcessor postProcessor;
 
-    EntityRowReader(RowDescriptor descriptor, EntityResultSegment segmentMetadata) {
+    EntityRowReader(RowDescriptor descriptor, EntityResultSegment segmentMetadata, DataRowPostProcessor
postProcessor) {
+
+        this.postProcessor = postProcessor;
 
         ClassDescriptor classDescriptor = segmentMetadata.getClassDescriptor();
 
@@ -78,11 +80,6 @@ class EntityRowReader implements RowRead
     }
 
     @Override
-    public void setPostProcessor(DataRowPostProcessor postProcessor) {
-        this.postProcessor = postProcessor;
-    }
-
-    @Override
     public DataRow readRow(ResultSet resultSet) {
 
         try {

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/FullRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/FullRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/FullRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/FullRowReader.java
Wed Mar 12 15:13:29 2014
@@ -32,8 +32,8 @@ class FullRowReader extends BaseRowReade
 
     int mapCapacity;
 
-    FullRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata) {
-        super(descriptor, queryMetadata);
+    FullRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata, DataRowPostProcessor
postProcessor) {
+        super(descriptor, queryMetadata, postProcessor);
         this.mapCapacity = (int) Math.ceil((descriptor.getWidth()) / 0.75);
     }
 

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/IdRowReader.java
Wed Mar 12 15:13:29 2014
@@ -34,8 +34,8 @@ class IdRowReader<T> extends BaseRowRead
 
     protected int[] pkIndices;
 
-    public IdRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata) {
-        super(descriptor, queryMetadata);
+    public IdRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata, DataRowPostProcessor
postProcessor) {
+        super(descriptor, queryMetadata, postProcessor);
 
         DbEntity dbEntity = queryMetadata.getDbEntity();
         if (dbEntity == null) {

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareEntityRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareEntityRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareEntityRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareEntityRowReader.java
Wed Mar 12 15:13:29 2014
@@ -32,13 +32,11 @@ class InheritanceAwareEntityRowReader ex
 
     private EntityInheritanceTree entityInheritanceTree;
 
-    public InheritanceAwareEntityRowReader(RowDescriptor descriptor,
-            EntityResultSegment segmentMetadata) {
-        super(descriptor, segmentMetadata);
-
-        entityInheritanceTree = segmentMetadata
-                .getClassDescriptor()
-                .getEntityInheritanceTree();
+    public InheritanceAwareEntityRowReader(RowDescriptor descriptor, EntityResultSegment
segmentMetadata,
+            DataRowPostProcessor postProcessor) {
+        
+        super(descriptor, segmentMetadata, postProcessor);
+        this.entityInheritanceTree = segmentMetadata.getClassDescriptor().getEntityInheritanceTree();
     }
 
     @Override

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/InheritanceAwareRowReader.java
Wed Mar 12 15:13:29 2014
@@ -32,11 +32,9 @@ class InheritanceAwareRowReader extends 
 
     private EntityInheritanceTree entityInheritanceTree;
 
-    InheritanceAwareRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata) {
-        super(descriptor, queryMetadata);
-        this.entityInheritanceTree = queryMetadata
-                .getClassDescriptor()
-                .getEntityInheritanceTree();
+    InheritanceAwareRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata, DataRowPostProcessor
postProcessor) {
+        super(descriptor, queryMetadata, postProcessor);
+        this.entityInheritanceTree = queryMetadata.getClassDescriptor().getEntityInheritanceTree();
     }
 
     @Override

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/JDBCResultIterator.java
Wed Mar 12 15:13:29 2014
@@ -186,13 +186,4 @@ public class JDBCResultIterator<T> imple
     public void setClosingConnection(boolean flag) {
         // noop
     }
-    
-    // TODO: andrus 11/27/2008 refactor the postprocessor hack into a special
-    // row reader.
-    void setPostProcessor(DataRowPostProcessor postProcessor) {
-
-        if (rowReader != null) {
-            rowReader.setPostProcessor(postProcessor);
-        }
-    }
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReader.java
Wed Mar 12 15:13:29 2014
@@ -21,8 +21,8 @@ package org.apache.cayenne.access.jdbc;
 import java.sql.ResultSet;
 
 /**
- * A strategy class that encapsulates an algorithm for converting a single ResultSet row
- * into a DataRow.
+ * A strategy class that encapsulates an algorithm for converting a single
+ * ResultSet row into a DataRow.
  * 
  * @since 3.0
  */
@@ -32,7 +32,4 @@ interface RowReader<T> {
      * Extracts a DataRow from the ResultSet at its current position.
      */
     T readRow(ResultSet resultSet);
-
-    // TODO: andrus 11/27/2008 refactor the postprocessor hack into a special row reader.
-    void setPostProcessor(DataRowPostProcessor postProcessor);
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReaderFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReaderFactory.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReaderFactory.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/RowReaderFactory.java
Wed Mar 12 15:13:29 2014
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.access.jdbc;
 
+import org.apache.cayenne.access.trans.SelectTranslator;
 import org.apache.cayenne.query.QueryMetadata;
 
 /**
@@ -27,5 +28,5 @@ import org.apache.cayenne.query.QueryMet
  */
 public interface RowReaderFactory {
 
-    RowReader<?> createRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata);
+    RowReader<?> createRowReader(RowDescriptor descriptor, QueryMetadata queryMetadata,
SelectTranslator translator);
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
Wed Mar 12 15:13:29 2014
@@ -199,7 +199,7 @@ public class SQLTemplateAction implement
 
         ExtendedTypeMap types = getAdapter().getExtendedTypes();
         RowDescriptorBuilder builder = configureRowDescriptorBuilder(compiled, resultSet);
-        RowReader<?> rowReader = rowReaderFactory.createRowReader(builder.getDescriptor(types),
queryMetadata);
+        RowReader<?> rowReader = rowReaderFactory.createRowReader(builder.getDescriptor(types),
queryMetadata, null);
 
         JDBCResultIterator result = new JDBCResultIterator(statement, resultSet, rowReader);
 

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/ScalarRowReader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/ScalarRowReader.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/ScalarRowReader.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/ScalarRowReader.java
Wed Mar 12 15:13:29 2014
@@ -54,9 +54,4 @@ class ScalarRowReader<T> implements RowR
             throw new CayenneRuntimeException("Exception materializing column.", Util.unwindException(otherex));
         }
     }
-
-    @Override
-    public void setPostProcessor(DataRowPostProcessor postProcessor) {
-        // noop
-    }
 }

Modified: cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
Wed Mar 12 15:13:29 2014
@@ -92,12 +92,10 @@ public class SelectAction extends BaseSQ
         RowDescriptor descriptor = new RowDescriptorBuilder().setColumns(translator.getResultColumns()).getDescriptor(
                 getAdapter().getExtendedTypes());
         
-        RowReader<?> rowReader = rowReaderFactory.createRowReader(descriptor, md);
+        RowReader<?> rowReader = rowReaderFactory.createRowReader(descriptor, md, translator);
 
         JDBCResultIterator workerIterator = new JDBCResultIterator(prepStmt, rs, rowReader);
 
-        workerIterator.setPostProcessor(DataRowPostProcessor.createPostProcessor(translator));
-
         ResultIterator it = workerIterator;
 
         if (observer.isIteratedResult()) {

Modified: cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java?rev=1576776&r1=1576775&r2=1576776&view=diff
==============================================================================
--- cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
(original)
+++ cayenne/main/trunk/cayenne-server/src/test/java/org/apache/cayenne/access/jdbc/JDBCResultIteratorTest.java
Wed Mar 12 15:13:29 2014
@@ -43,7 +43,7 @@ public class JDBCResultIteratorTest exte
         rs.addColumn("a", new Object[] { "1", "2", "3" });
         
         RowDescriptor descriptor = new RowDescriptorBuilder().setResultSet(rs).getDescriptor(new
ExtendedTypeMap());
-        RowReader<?> rowReader = new DefaultRowReaderFactory().createRowReader(descriptor,
new MockQueryMetadata());
+        RowReader<?> rowReader = new DefaultRowReaderFactory().createRowReader(descriptor,
new MockQueryMetadata(), null);
 
         JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);
 



Mime
View raw message