openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r426710 [1/6] - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/sr...
Date Fri, 28 Jul 2006 23:48:18 GMT
Author: awhite
Date: Fri Jul 28 16:48:13 2006
New Revision: 426710

URL: http://svn.apache.org/viewvc?rev=426710&view=rev
Log:
Cleanup of fetch group metadata and internal runtime APIs. Now that fetch depth
information is immutable within a fetch instance and cloned on relation 
traversal, it was safe to combine fetch state back into the fetch configuration 
class and remove the fetch state class for cleaner APIs (no more having some
components use fetch state and others fetch configuration). Also changed
recursion depth logic to more accurately mirror intent (per JDO spec), though 
testing is needed. 


Added:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/StoreFacadeTypeRegistry.java
Removed:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchState.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchStateImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/StoreFacadeTypeRegistry.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchState.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchStateImpl.java
Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/GenericResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/InstanceResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStore.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MappedQueryResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SelectResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AbstractVal.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Aggregate.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AndExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Args.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/BindVariableAndExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/BindVariableExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CompareEqualExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CompareExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Concat.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Const.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ConstGetObjectId.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ConstInstanceofExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/ConstPath.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/CurrentDate.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/EmptyExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/EndsWithExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/EqualExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Exp.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Extension.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/FilterValueImpl.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/GetObjectId.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InSubQExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/IndexOf.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/InstanceofExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/IsEmptyExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/IsNotEmptyExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/JDBCExpressionFactory.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Lit.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/MatchesExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Math.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NotContainsExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NotEqualExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/NotExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Null.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/OrExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/PCPath.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Param.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Size.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/StartsWithExpression.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/StringFunction.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SubQ.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Substring.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Trim.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/UnaryOp.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Val.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/Variable.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Embeddable.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ValueHandler.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractValueHandler.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/EmbedValueHandler.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerHandlerMapTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerStrategies.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSCollectionFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSMapFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyCollection.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/LRSProxyMap.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedLobFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/PrimitiveFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionInverseKeyFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationCollectionTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapInverseKeyFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationMapTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StoreCollectionFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/StringFieldStrategy.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/UntypedPCValueHandler.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/AbstractResult.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MergedResult.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Result.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCDataGenerator.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractPCResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBroker.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingStoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedValueStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/OpenJPAStateManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCDataImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/PCResultObjectProvider.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ROPStoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreContext.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionAttachStrategy.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FetchGroup.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ImplHelper.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchAttribute.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchGroup.java
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/FetchPlan.java
    incubator/openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/ObjectData.java
    incubator/openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStoreManager.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/DelegatingJDBCFetchConfiguration.java Fri Jul 28 16:48:13 2006
@@ -20,6 +20,7 @@
 
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
+import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.util.RuntimeExceptionTranslator;
 
 ///////////////////////////////////////////////////////////////
@@ -227,6 +228,14 @@
         try {
             getJDBCDelegate().clearJoins();
             return this;
+        } catch (RuntimeException re) {
+            throw translate(re);
+        }
+    }
+
+    public JDBCFetchConfiguration traverseJDBC(FieldMetaData fm) {
+        try {
+            return getJDBCDelegate().traverseJDBC(fm);
         } catch (RuntimeException re) {
             throw translate(re);
         }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/GenericResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/GenericResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/GenericResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/GenericResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -87,9 +87,8 @@
         throws SQLException {
         // rather than use the standard result.load(), we go direct to
         // the store manager so we can tell it not to load anything additional
-        return ((JDBCStoreManager) _store).load(_mapping,
-            (JDBCFetchState) _fetch.newFetchState(), StoreContext.EXCLUDE_ALL,
-            _res);
+        return ((JDBCStoreManager) _store).load(_mapping, _fetch,
+            StoreContext.EXCLUDE_ALL, _res);
     }
 
     public boolean next()

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/InstanceResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/InstanceResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/InstanceResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/InstanceResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -42,8 +42,8 @@
      * @param fetch the fetch configuration, or null for default
      */
     public InstanceResultObjectProvider(SelectExecutor sel,
-        ClassMapping mapping, JDBCStore store, JDBCFetchState fetchState) {
-        super(sel, store, fetchState);
+        ClassMapping mapping, JDBCStore store, JDBCFetchConfiguration fetch) {
+        super(sel, store, fetch);
         _mapping = mapping;
     }
 
@@ -53,6 +53,6 @@
         ClassMapping mapping = res.getBaseMapping();
         if (mapping == null)
             mapping = _mapping;
-        return res.load(mapping, getStore(), (JDBCFetchState) getFetchState());
+        return res.load(mapping, getStore(), getFetchConfiguration());
     }
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfiguration.java Fri Jul 28 16:48:13 2006
@@ -22,6 +22,7 @@
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
 import org.apache.openjpa.kernel.FetchConfiguration;
+import org.apache.openjpa.meta.FieldMetaData;
 
 /**
  * JDBC extensions to OpenJPA's {@link FetchConfiguration}.
@@ -163,4 +164,9 @@
      * @since 4.0.0
      */
     public JDBCFetchConfiguration clearJoins();
+
+    /**
+     * Convenience method to cast traversal to store-specific type.
+     */
+    public JDBCFetchConfiguration traverseJDBC(FieldMetaData fm);
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCFetchConfigurationImpl.java Fri Jul 28 16:48:13 2006
@@ -28,7 +28,6 @@
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.kernel.FetchConfiguration;
 import org.apache.openjpa.kernel.FetchConfigurationImpl;
-import org.apache.openjpa.kernel.FetchState;
 import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.lib.rop.EagerResultList;
 import org.apache.openjpa.lib.rop.ListResultObjectProvider;
@@ -38,6 +37,7 @@
 import org.apache.openjpa.lib.rop.SoftRandomAccessResultList;
 import org.apache.openjpa.lib.rop.WindowResultList;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.util.UserException;
 
 /**
@@ -53,13 +53,35 @@
     private static final Localizer _loc = Localizer.forPackage
         (JDBCFetchConfigurationImpl.class);
 
-    private int _eagerMode = 0;
-    private int _subclassMode = 0;
-    private int _type = 0;
-    private int _direction = 0;
-    private int _size = 0;
-    private int _syntax = 0;
-    private Set _joins = null;
+    /**
+     * Configurable JDBC state shared throughout a traversal chain.
+     */
+    private static class JDBCConfigurationState {
+        public int eagerMode = 0;
+        public int subclassMode = 0;
+        public int type = 0;
+        public int direction = 0;
+        public int size = 0;
+        public int syntax = 0;
+        public Set joins = null;
+    }
+
+    private final JDBCConfigurationState _state;
+
+    public JDBCFetchConfigurationImpl() {
+        this(null, null);
+    }
+
+    private JDBCFetchConfigurationImpl(ConfigurationState state, 
+        JDBCConfigurationState jstate) {
+        super(state);
+        _state = (jstate == null) ? new JDBCConfigurationState() : jstate;
+    }
+
+    protected FetchConfigurationImpl newInstance(ConfigurationState state) {
+        JDBCConfigurationState jstate = (state == null) ? null : _state;
+        return new JDBCFetchConfigurationImpl(state, jstate);
+    }
 
     public void setContext(StoreContext ctx) {
         super.setContext(ctx);
@@ -75,11 +97,6 @@
         setJoinSyntax(conf.getDBDictionaryInstance().joinSyntax);
     }
 
-    protected FetchConfigurationImpl newInstance() {
-        JDBCFetchConfigurationImpl fetch = new JDBCFetchConfigurationImpl();
-        return fetch;
-    }
-
     public void copy(FetchConfiguration fetch) {
         super.copy(fetch);
         JDBCFetchConfiguration jf = (JDBCFetchConfiguration) fetch;
@@ -93,7 +110,7 @@
     }
 
     public int getEagerFetchMode() {
-        return _eagerMode;
+        return _state.eagerMode;
     }
 
     public JDBCFetchConfiguration setEagerFetchMode(int mode) {
@@ -103,21 +120,21 @@
                 mode = conf.getEagerFetchModeConstant();
         }
         if (mode != DEFAULT)
-            _eagerMode = mode;
+            _state.eagerMode = mode;
         return this;
     }
 
     public int getSubclassFetchMode() {
-        return _subclassMode;
+        return _state.subclassMode;
     }
 
     public int getSubclassFetchMode(ClassMapping cls) {
         if (cls == null)
-            return _subclassMode;
+            return _state.subclassMode;
         int mode = cls.getSubclassFetchMode();
         if (mode == DEFAULT)
-            return _subclassMode;
-        return Math.min(mode, _subclassMode);
+            return _state.subclassMode;
+        return Math.min(mode, _state.subclassMode);
     }
 
     public JDBCFetchConfiguration setSubclassFetchMode(int mode) {
@@ -127,63 +144,63 @@
                 mode = conf.getSubclassFetchModeConstant();
         }
         if (mode != DEFAULT)
-            _subclassMode = mode;
+            _state.subclassMode = mode;
         return this;
     }
 
     public int getResultSetType() {
-        return _type;
+        return _state.type;
     }
 
     public JDBCFetchConfiguration setResultSetType(int type) {
         if (type == DEFAULT) {
             JDBCConfiguration conf = getJDBCConfiguration();
             if (conf != null)
-                _type = conf.getResultSetTypeConstant();
+                _state.type = conf.getResultSetTypeConstant();
         } else
-            _type = type;
+            _state.type = type;
         return this;
     }
 
     public int getFetchDirection() {
-        return _direction;
+        return _state.direction;
     }
 
     public JDBCFetchConfiguration setFetchDirection(int direction) {
         if (direction == DEFAULT) {
             JDBCConfiguration conf = getJDBCConfiguration();
             if (conf != null)
-                _direction = conf.getFetchDirectionConstant();
+                _state.direction = conf.getFetchDirectionConstant();
         } else
-            _direction = direction;
+            _state.direction = direction;
         return this;
     }
 
     public int getLRSSize() {
-        return _size;
+        return _state.size;
     }
 
     public JDBCFetchConfiguration setLRSSize(int size) {
         if (size == DEFAULT) {
             JDBCConfiguration conf = getJDBCConfiguration();
             if (conf != null)
-                _size = conf.getLRSSizeConstant();
+                _state.size = conf.getLRSSizeConstant();
         } else
-            _size = size;
+            _state.size = size;
         return this;
     }
 
     public int getJoinSyntax() {
-        return _syntax;
+        return _state.syntax;
     }
 
     public JDBCFetchConfiguration setJoinSyntax(int syntax) {
         if (syntax == DEFAULT) {
             JDBCConfiguration conf = getJDBCConfiguration();
             if (conf != null)
-                _syntax = conf.getDBDictionaryInstance().joinSyntax;
+                _state.syntax = conf.getDBDictionaryInstance().joinSyntax;
         } else
-            _syntax = syntax;
+            _state.syntax = syntax;
         return this;
     }
 
@@ -203,8 +220,8 @@
             return new EagerResultList(rop);
 
         // if foward only or forward direction use a forward window
-        if (_type == ResultSet.TYPE_FORWARD_ONLY
-            || _direction == ResultSet.FETCH_FORWARD
+        if (_state.type == ResultSet.TYPE_FORWARD_ONLY
+            || _state.direction == ResultSet.FETCH_FORWARD
             || !rop.supportsRandomAccess()) {
             if (getFetchBatchSize() > 0 && getFetchBatchSize() <= 50)
                 return new WindowResultList(rop, getFetchBatchSize());
@@ -212,7 +229,7 @@
         }
 
         // if skipping around use a caching random access list
-        if (_direction == ResultSet.FETCH_UNKNOWN)
+        if (_state.direction == ResultSet.FETCH_UNKNOWN)
             return new SoftRandomAccessResultList(rop);
 
         // scrolling reverse... just use non-caching simple result list
@@ -220,11 +237,11 @@
     }
 
     public Set getJoins() {
-        return (_joins == null) ? Collections.EMPTY_SET : _joins;
+        return (_state.joins == null) ? Collections.EMPTY_SET : _state.joins;
     }
 
     public boolean hasJoin(String field) {
-        return _joins != null && _joins.contains(field);
+        return _state.joins != null && _state.joins.contains(field);
     }
 
     public JDBCFetchConfiguration addJoin(String join) {
@@ -233,9 +250,9 @@
         
         lock();
         try {
-            if (_joins == null)
-                _joins = new HashSet();
-            _joins.add(join);
+            if (_state.joins == null)
+                _state.joins = new HashSet();
+            _state.joins.add(join);
         } finally {
             unlock();
         }
@@ -253,8 +270,8 @@
     public JDBCFetchConfiguration removeJoin(String field) {
         lock();
         try {
-            if (_joins != null)
-                _joins.remove(field);
+            if (_state.joins != null)
+                _state.joins.remove(field);
         } finally {
             unlock();
         }
@@ -264,8 +281,8 @@
     public JDBCFetchConfiguration removeJoins(Collection joins) {
         lock();
         try {
-            if (_joins != null)
-                _joins.removeAll(joins);
+            if (_state.joins != null)
+                _state.joins.removeAll(joins);
         } finally {
             unlock();
         }
@@ -275,16 +292,16 @@
     public JDBCFetchConfiguration clearJoins() {
         lock();
         try {
-            if (_joins != null)
-                _joins.clear();
+            if (_state.joins != null)
+                _state.joins.clear();
         } finally {
             unlock();
         }
         return this;
     }
 
-    public FetchState newFetchState() {
-        return new JDBCFetchStateImpl(this);
+    public JDBCFetchConfiguration traverseJDBC(FieldMetaData fm) {
+        return (JDBCFetchConfiguration) traverse(fm);
     }
 
     /**

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStore.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStore.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStore.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStore.java Fri Jul 28 16:48:13 2006
@@ -86,7 +86,7 @@
      * @param vm the mapping holding this oid, or null if not applicable
      */
     public Object find(Object oid, ValueMapping vm,
-        JDBCFetchState fetchState);
+        JDBCFetchConfiguration fetch);
 
     /**
      * Makes sure all subclasses of the given type are loaded in the JVM.

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java Fri Jul 28 16:48:13 2006
@@ -46,7 +46,6 @@
 import org.apache.openjpa.jdbc.sql.SelectExecutor;
 import org.apache.openjpa.jdbc.sql.Union;
 import org.apache.openjpa.kernel.FetchConfiguration;
-import org.apache.openjpa.kernel.FetchState;
 import org.apache.openjpa.kernel.LockManager;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.PCState;
@@ -142,12 +141,6 @@
         return (JDBCFetchConfiguration) _ctx.getFetchConfiguration();
     }
 
-    private JDBCFetchConfiguration getFetchConfiguration(
-        JDBCFetchState fetchState) {
-        return (fetchState == null) ? getFetchConfiguration() : fetchState
-            .getJDBCFetchConfiguration();
-    }
-
     public void beginOptimistic() {
     }
 
@@ -254,10 +247,11 @@
     }
 
     public boolean initialize(OpenJPAStateManager sm, PCState state,
-        FetchState fetchState, Object context) {
+        FetchConfiguration fetch, Object context) {
         ConnectionInfo info = (ConnectionInfo) context;
         try {
-            return initializeState(sm, state, (JDBCFetchState) fetchState, info);
+            return initializeState(sm, state, (JDBCFetchConfiguration)fetch, 
+                info);
         } catch (ClassNotFoundException cnfe) {
             throw new UserException(cnfe);
         } catch (SQLException se) {
@@ -269,11 +263,10 @@
      * Initialize a newly-loaded instance.
      */
     private boolean initializeState(OpenJPAStateManager sm, PCState state,
-        JDBCFetchState fetchState, ConnectionInfo info)
+        JDBCFetchConfiguration fetch, ConnectionInfo info)
         throws ClassNotFoundException, SQLException {
         Object oid = sm.getObjectId();
         ClassMapping mapping = (ClassMapping) sm.getMetaData();
-        JDBCFetchConfiguration jfetch = getFetchConfiguration(fetchState);
         Result res = null;
         if (info != null && info.result != null) {
             res = info.result;
@@ -283,30 +276,30 @@
             mapping = info.mapping;
         } else if (oid instanceof OpenJPAId
             && !((OpenJPAId) oid).hasSubclasses()) {
-            Boolean custom = customLoad(sm, mapping, state, jfetch);
+            Boolean custom = customLoad(sm, mapping, state, fetch);
             if (custom != null)
                 return custom.booleanValue();
-            res = getInitializeStateResult(sm, mapping, fetchState,
+            res = getInitializeStateResult(sm, mapping, fetch,
                 Select.SUBS_EXACT);
-            if (res == null && !selectPrimaryKey(sm, mapping, jfetch))
+            if (res == null && !selectPrimaryKey(sm, mapping, fetch))
                 return false;
             if (res != null && !res.next())
                 return false;
         } else {
-            ClassMapping[] mappings = mapping
-                .getIndependentAssignableMappings();
+            ClassMapping[] mappings = mapping.
+                getIndependentAssignableMappings();
             if (mappings.length == 1) {
                 mapping = mappings[0];
-                Boolean custom = customLoad(sm, mapping, state, jfetch);
+                Boolean custom = customLoad(sm, mapping, state, fetch);
                 if (custom != null)
                     return custom.booleanValue();
-                res = getInitializeStateResult(sm, mapping, fetchState,
+                res = getInitializeStateResult(sm, mapping, fetch,
                     Select.SUBS_ANY_JOINABLE);
-                if (res == null && !selectPrimaryKey(sm, mapping, jfetch))
+                if (res == null && !selectPrimaryKey(sm, mapping, fetch))
                     return false;
             } else
                 res = getInitializeStateUnionResult(sm, mapping, mappings,
-                    fetchState);
+                    fetch);
             if (res != null && !res.next())
                 return false;
         }
@@ -338,8 +331,7 @@
             if (res != null) {
                 // re-get the mapping in case the instance was a subclass
                 mapping = (ClassMapping) sm.getMetaData();
-
-                load(mapping, sm, fetchState, res);
+                load(mapping, sm, fetch, res);
                 mapping.getVersion().afterLoad(sm, this);
             }
             return true;
@@ -354,10 +346,10 @@
      * does not use custom loading.
      */
     private Boolean customLoad(OpenJPAStateManager sm, ClassMapping mapping,
-        PCState state, JDBCFetchConfiguration jfetch)
+        PCState state, JDBCFetchConfiguration fetch)
         throws ClassNotFoundException, SQLException {
         // check to see if the mapping takes care of initialization
-        if (!mapping.customLoad(sm, this, state, jfetch))
+        if (!mapping.customLoad(sm, this, state, fetch))
             return null;
         if (sm.getManagedInstance() != null) {
             mapping.getVersion().afterLoad(sm, this);
@@ -371,15 +363,15 @@
      * null if there is no data in the current fetch groups to select.
      */
     private Result getInitializeStateResult(OpenJPAStateManager sm,
-        ClassMapping mapping, JDBCFetchState fetchState, int subs)
+        ClassMapping mapping, JDBCFetchConfiguration fetch, int subs)
         throws SQLException {
         Select sel = _sql.newSelect();
-        if (!select(sel, mapping, subs, sm, null, fetchState,
+        if (!select(sel, mapping, subs, sm, null, fetch,
             JDBCFetchConfiguration.EAGER_JOIN, true))
             return null;
 
         sel.wherePrimaryKey(sm.getObjectId(), mapping, this);
-        return sel.execute(this, getFetchConfiguration(fetchState));
+        return sel.execute(this, fetch);
     }
 
     /**
@@ -388,25 +380,23 @@
      */
     private Result getInitializeStateUnionResult(final OpenJPAStateManager sm,
         ClassMapping mapping, final ClassMapping[] mappings,
-        final JDBCFetchState fetchState) throws SQLException {
+        final JDBCFetchConfiguration fetch) throws SQLException {
         final JDBCStoreManager store = this;
-        JDBCFetchConfiguration jfetch = getFetchConfiguration(fetchState);
-        final int eager = Math.min(jfetch.getEagerFetchMode(),
+        final int eager = Math.min(fetch.getEagerFetchMode(),
             JDBCFetchConfiguration.EAGER_JOIN);
 
         Union union = _sql.newUnion(mappings.length);
         union.setSingleResult(true);
-        if (jfetch.getSubclassFetchMode(mapping) != jfetch.EAGER_JOIN)
+        if (fetch.getSubclassFetchMode(mapping) != fetch.EAGER_JOIN)
             union.abortUnion();
         union.select(new Union.Selector() {
-
             public void select(Select sel, int i) {
-                sel.select(mappings[i], Select.SUBS_ANY_JOINABLE, store,
-                    fetchState, eager);
+                sel.select(mappings[i], Select.SUBS_ANY_JOINABLE, store, fetch,
+                    eager);
                 sel.wherePrimaryKey(sm.getObjectId(), mappings[i], store);
             }
         });
-        return union.execute(this, jfetch);
+        return union.execute(this, fetch);
     }
 
     /**
@@ -414,7 +404,7 @@
      * if needed.
      */
     private boolean selectPrimaryKey(OpenJPAStateManager sm,
-        ClassMapping mapping, JDBCFetchConfiguration jfetch)
+        ClassMapping mapping, JDBCFetchConfiguration fetch)
         throws SQLException {
         // select pks from base class record to ensure it exists and lock
         // it if needed
@@ -425,7 +415,7 @@
         Select sel = _sql.newSelect();
         sel.select(base.getPrimaryKeyColumns());
         sel.wherePrimaryKey(sm.getObjectId(), base, this);
-        Result exists = sel.execute(this, jfetch);
+        Result exists = sel.execute(this, fetch);
         try {
             if (!exists.next())
                 return false;
@@ -440,9 +430,8 @@
     }
 
     public boolean load(OpenJPAStateManager sm, BitSet fields,
-        FetchState fetchState, int lockLevel, Object context) {
-        JDBCFetchState jfetchState = (JDBCFetchState) fetchState;
-        JDBCFetchConfiguration jfetch = getFetchConfiguration(jfetchState);
+        FetchConfiguration fetch, int lockLevel, Object context) {
+        JDBCFetchConfiguration jfetch = (JDBCFetchConfiguration) fetch;
 
         // get a connection, or reuse current one
         ConnectionInfo info = (ConnectionInfo) context;
@@ -459,7 +448,7 @@
             // if there's an existing result, load all we can from it
             ClassMapping mapping = (ClassMapping) sm.getMetaData();
             if (res != null) {
-                load(mapping, sm, jfetchState, res);
+                load(mapping, sm, jfetch, res);
                 removeLoadedFields(sm, fields);
             }
 
@@ -474,25 +463,24 @@
             //### object that only creates a real select when actually used?
 
             Select sel = _sql.newSelect();
-            if (select(sel, mapping, sel.SUBS_EXACT, sm, fields, jfetchState,
-                jfetch.EAGER_JOIN, true)) {
+            if (select(sel, mapping, sel.SUBS_EXACT, sm, fields, jfetch,
+                EagerFetchModes.EAGER_JOIN, true)) {
                 sel.wherePrimaryKey(sm.getObjectId(), mapping, this);
                 res = sel.execute(this, jfetch, lockLevel);
                 try {
                     if (!res.next())
                         return false;
-                    load(mapping, sm, jfetchState, res);
+                    load(mapping, sm, jfetch, res);
                 } finally {
                     res.close();
                 }
             }
 
             // now allow the fields to load themselves individually too
-            for (int i = 0, len = fields.length(); i < len; i++)
-                if (fields.get(i) && !sm.getLoaded().get(i)) {
-                	FieldMapping fm = mapping.getFieldMapping(i);
-                    fm.load(sm, this, (JDBCFetchState)jfetchState.traverse(fm));
-                }
+            FieldMapping[] fms = mapping.getFieldMappings();
+            for (int i = 0; i < fms.length; i++)
+                if (fields.get(i) && !sm.getLoaded().get(i))
+                    fms[i].load(sm, this, jfetch.traverseJDBC(fms[i]));
             mapping.getVersion().afterLoad(sm, this);
             return true;
         } catch (ClassNotFoundException cnfe) {
@@ -605,8 +593,6 @@
 
         ResultObjectProvider[] rops = null;
         final JDBCFetchConfiguration jfetch = (JDBCFetchConfiguration) fetch;
-        final JDBCFetchState jfetchState = (JDBCFetchState) jfetch
-            .newFetchState();
         if (jfetch.getSubclassFetchMode(mapping) != jfetch.EAGER_JOIN)
             rops = new ResultObjectProvider[mappings.length];
 
@@ -633,15 +619,14 @@
 
                     Select sel = _sql.newSelect();
                     sel.setLRS(true);
-                    BitSet paged = selectExtent(sel, mappings[i], jfetchState,
+                    BitSet paged = selectExtent(sel, mappings[i], jfetch,
                         subclasses);
                     if (paged == null)
                         rops[i] = new InstanceResultObjectProvider(sel,
-                            mappings[i], this, jfetchState);
+                            mappings[i], this, jfetch);
                     else
                         rops[i] = new PagingResultObjectProvider(sel,
-                            mappings[i], this, jfetchState, paged,
-                            Long.MAX_VALUE);
+                            mappings[i], this, jfetch, paged, Long.MAX_VALUE);
                 }
                 if (rops.length == 1)
                     return rops[0];
@@ -653,9 +638,8 @@
             union.setLRS(true);
             final BitSet[] paged = new BitSet[mappings.length];
             union.select(new Union.Selector() {
-
                 public void select(Select sel, int idx) {
-                    paged[idx] = selectExtent(sel, mappings[idx], jfetchState,
+                    paged[idx] = selectExtent(sel, mappings[idx], jfetch,
                         subclasses);
                 }
             });
@@ -664,11 +648,10 @@
             for (int i = 0; i < paged.length; i++) {
                 if (paged[i] != null)
                     return new PagingResultObjectProvider(union, mappings,
-                        JDBCStoreManager.this, jfetchState, paged,
-                        Long.MAX_VALUE);
+                        JDBCStoreManager.this, jfetch, paged, Long.MAX_VALUE);
             }
             return new InstanceResultObjectProvider(union, mappings[0], this,
-                jfetchState);
+                jfetch);
         } catch (SQLException se) {
             throw SQLExceptions.getStore(se, _dict);
         }
@@ -678,17 +661,17 @@
      * Select the given mapping for use in an extent, returning paged fields.
      */
     private BitSet selectExtent(Select sel, ClassMapping mapping,
-        JDBCFetchState jfetchState, boolean subclasses) {
+        JDBCFetchConfiguration fetch, boolean subclasses) {
         int subs = (subclasses) ? Select.SUBS_JOINABLE : Select.SUBS_NONE;
         // decide between paging and standard iteration
         BitSet paged = PagingResultObjectProvider.getPagedFields(sel, mapping,
-            this, jfetchState, JDBCFetchConfiguration.EAGER_PARALLEL,
+            this, fetch, JDBCFetchConfiguration.EAGER_PARALLEL,
             Long.MAX_VALUE);
         if (paged == null)
-            sel.selectIdentifier(mapping, subs, this, jfetchState,
+            sel.selectIdentifier(mapping, subs, this, fetch,
                 JDBCFetchConfiguration.EAGER_PARALLEL);
         else
-            sel.selectIdentifier(mapping, subs, this, jfetchState,
+            sel.selectIdentifier(mapping, subs, this, fetch,
                 JDBCFetchConfiguration.EAGER_JOIN);
         return paged;
     }
@@ -756,10 +739,11 @@
     /**
      * Find the object with the given oid.
      */
-    public Object find(Object oid, ValueMapping vm, JDBCFetchState fetchState) {
+    public Object find(Object oid, ValueMapping vm, 
+        JDBCFetchConfiguration fetch) {
         if (oid == null)
             return null;
-        Object pc = _ctx.find(oid, fetchState, null, null, 0);
+        Object pc = _ctx.find(oid, fetch, null, null, 0);
         if (pc == null && vm != null) {
             OrphanedKeyAction action = _conf.getOrphanedKeyActionInstance();
             pc = action.orphan(oid, null, vm);
@@ -770,7 +754,7 @@
     /**
      * Load the object in the current row of the given result.
      */
-    public Object load(ClassMapping mapping, JDBCFetchState fetchState,
+    public Object load(ClassMapping mapping, JDBCFetchConfiguration fetch,
         BitSet exclude, Result result) throws SQLException {
         if (!mapping.isMapped())
             throw new InvalidStateException(_loc
@@ -787,7 +771,7 @@
         ConnectionInfo info = new ConnectionInfo();
         info.result = result;
         info.mapping = mapping;
-        return _ctx.find(oid, fetchState, exclude, info, 0);
+        return _ctx.find(oid, fetch, exclude, info, 0);
     }
 
     /**
@@ -795,11 +779,11 @@
      * mappings originally selected will be loaded.
      */
     private void load(ClassMapping mapping, OpenJPAStateManager sm,
-        JDBCFetchState fetchState, Result res) throws SQLException {
-        FieldMapping eagerToMany = load(mapping, sm, fetchState, res, null);
+        JDBCFetchConfiguration fetch, Result res) throws SQLException {
+        FieldMapping eagerToMany = load(mapping, sm, fetch, res, null);
         if (eagerToMany != null)
-            eagerToMany.loadEagerJoin(sm, this, 
-            	(JDBCFetchState)fetchState.traverse(eagerToMany), res);
+            eagerToMany.loadEagerJoin(sm, this, fetch.traverseJDBC(eagerToMany),
+                res);
         if (_active && _lm != null && res.isLocking())
             _lm.loadedForUpdate(sm);
     }
@@ -809,16 +793,15 @@
      * without loading it.
      */
     private FieldMapping load(ClassMapping mapping, OpenJPAStateManager sm,
-        JDBCFetchState fetchState, Result res, FieldMapping eagerToMany)
+        JDBCFetchConfiguration fetch, Result res, FieldMapping eagerToMany)
         throws SQLException {
-        JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
         if (mapping.customLoad(sm, this, fetch, res))
             return eagerToMany;
 
         // load superclass data; base class loads version
         ClassMapping parent = mapping.getJoinablePCSuperclassMapping();
         if (parent != null)
-            eagerToMany = load(parent, sm, fetchState, res, eagerToMany);
+            eagerToMany = load(parent, sm, fetch, res, eagerToMany);
         else if (sm.getVersion() == null)
             mapping.getVersion().load(sm, this, res);
 
@@ -838,15 +821,14 @@
                         eagerToMany = fms[i];
                     else
                         fms[i].loadEagerJoin(sm, this, 
-                        	(JDBCFetchState)fetchState.traverse(fms[i]), res);
+                        	fetch.traverseJDBC(fms[i]), res);
                 } else if (eres != null) {
                     processed = fms[i].loadEagerParallel(sm, this, 
-                    	(JDBCFetchState)fetchState.traverse(fms[i]), eres);
+                    	fetch.traverseJDBC(fms[i]), eres);
                     if (processed != eres)
                         res.putEager(fms[i], processed);
                 } else
-                    fms[i].load(sm, this, 
-                    	(JDBCFetchState)fetchState.traverse(fms[i]), res);
+                    fms[i].load(sm, this, fetch.traverseJDBC(fms[i]), res);
             } finally {
                 res.endDataRequest();
             }
@@ -867,7 +849,7 @@
      * initialized, else null
      * @param fields if a state manager is being loaded, the set of
      * fields that must be loaded in order, else null
-     * @param fetchState the fetch configuration; used if no specific fields
+     * @param fetch the fetch configuration; used if no specific fields
      * must be loaded, and used when selecting relations
      * @param eager eager fetch mode to use
      * @param ident whether to select primary key columns as distinct
@@ -875,7 +857,7 @@
      * @return true if the select is required, false otherwise
      */
     public boolean select(Select sel, ClassMapping mapping, int subs,
-        OpenJPAStateManager sm, BitSet fields, JDBCFetchState fetchState,
+        OpenJPAStateManager sm, BitSet fields, JDBCFetchConfiguration fetch,
         int eager, boolean ident) {
         // add class conditions so that they're cloned for any batched selects
         boolean joinedSupers = false;
@@ -887,27 +869,26 @@
         // create all our eager selects so that those fields are reserved
         // and cannot be reused during the actual eager select process,
         // preventing infinite recursion
-        JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
         eager = Math.min(eager, fetch.getEagerFetchMode());
         FieldMapping eagerToMany = createEagerSelects(sel, mapping, sm, fields,
-            fetchState, eager);
+            fetch, eager);
 
         // select all base class mappings; do this after batching so that
         // the joins needed by these selects don't get in the WHERE clause
         // of the batched selects
         int seld = selectBaseMappings(sel, mapping, mapping, sm, fields,
-            fetchState, eager, eagerToMany, ident, joinedSupers);
+            fetch, eager, eagerToMany, ident, joinedSupers);
 
         // select eager to-many relations last because during load they
         // advance the result set and could exhaust it, so no other mappings
         // can load afterwords
         if (eagerToMany != null)
             eagerToMany.selectEagerJoin(sel, sm, this, 
-            		(JDBCFetchState)fetchState.traverse(eagerToMany), eager);
+                fetch.traverseJDBC(eagerToMany), eager);
 
         // optionally select subclass mappings
         if (subs == sel.SUBS_JOINABLE || subs == sel.SUBS_ANY_JOINABLE)
-            selectSubclassMappings(sel, mapping, sm, fetchState);
+            selectSubclassMappings(sel, mapping, sm, fetch);
         if (sm != null)
             sel.setDistinct(false);
         return seld > 0;
@@ -918,14 +899,13 @@
      * get into infinite recursive situations.
      */
     private FieldMapping createEagerSelects(Select sel, ClassMapping mapping,
-        OpenJPAStateManager sm, BitSet fields, JDBCFetchState fetchState,
+        OpenJPAStateManager sm, BitSet fields, JDBCFetchConfiguration fetch,
         int eager) {
         if (mapping == null || eager == JDBCFetchConfiguration.EAGER_NONE)
             return null;
 
-        JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
-        FieldMapping eagerToMany = createEagerSelects(sel, mapping
-            .getJoinablePCSuperclassMapping(), sm, fields, fetchState, eager);
+        FieldMapping eagerToMany = createEagerSelects(sel, 
+            mapping.getJoinablePCSuperclassMapping(), sm, fields, fetch, eager);
 
         FieldMapping[] fms = mapping.getDefinedFieldMappings();
         boolean inEagerJoin = sel.hasEagerJoin(false);
@@ -936,7 +916,7 @@
             mode = fms[i].getEagerFetchMode();
             if (mode == fetch.EAGER_NONE)
                 continue;
-            if (!requiresSelect(fms[i], sm, fields, fetchState))
+            if (!requiresSelect(fms[i], sm, fields, fetch))
                 continue;
 
             // try to select with join first
@@ -981,13 +961,13 @@
      * Determine if the given field needs to be selected.
      */
     private static boolean requiresSelect(FieldMapping fm,
-        OpenJPAStateManager sm, BitSet fields, JDBCFetchState fetchState) {
+        OpenJPAStateManager sm, BitSet fields, JDBCFetchConfiguration fetch) {
         if (fields != null)
             return fields.get(fm.getIndex());
         if (sm != null && sm.getPCState() != PCState.TRANSIENT
             && sm.getLoaded().get(fm.getIndex()))
             return false;
-        return fetchState.requiresFetch(fm);
+        return fetch.requiresFetch(fm);
     }
 
     /**
@@ -1007,9 +987,8 @@
      */
     private int selectBaseMappings(Select sel, ClassMapping mapping,
         ClassMapping orig, OpenJPAStateManager sm, BitSet fields,
-        JDBCFetchState fetchState, int eager, FieldMapping eagerToMany,
+        JDBCFetchConfiguration fetch, int eager, FieldMapping eagerToMany,
         boolean ident, boolean joined) {
-        JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
         ClassMapping parent = mapping.getJoinablePCSuperclassMapping();
         if (parent == null && !mapping.isMapped())
             throw new InvalidStateException(_loc.get("virtual-mapping", mapping
@@ -1043,7 +1022,7 @@
         } else {
             // recurse on parent
             pseld = selectBaseMappings(sel, parent, orig, sm, fields,
-                fetchState, eager, eagerToMany, ident, joined);
+                fetch, eager, eagerToMany, ident, joined);
         }
 
         // select the mappings in the given fields set, or based on fetch
@@ -1062,18 +1041,18 @@
             if (esel != null) {
                 if (esel == sel)
                     fms[i].selectEagerJoin(sel, sm, this, 
-                    	(JDBCFetchState)fetchState.traverse(fms[i]), eager);
+                    	fetch.traverseJDBC(fms[i]), eager);
                 else
                     fms[i].selectEagerParallel(esel, sm, this, 
-                    	(JDBCFetchState)fetchState.traverse(fms[i]), eager);
+                    	fetch.traverseJDBC(fms[i]), eager);
                 seld = Math.max(0, seld);
-            } else if (requiresSelect(fms[i], sm, fields, fetchState)) {
+            } else if (requiresSelect(fms[i], sm, fields, fetch)) {
                 fseld = fms[i].select(sel, sm, this, 
-                	(JDBCFetchState)fetchState.traverse(fms[i]), eager);
+                	fetch.traverseJDBC(fms[i]), eager);
                 seld = Math.max(fseld, seld);
-            } else if (optSelect(fms[i], sel, sm, fetchState)) {
+            } else if (optSelect(fms[i], sel, sm, fetch)) {
                 fseld = fms[i].select(sel, sm, this, 
-                	(JDBCFetchState)fetchState.traverse(fms[i]), fetch.EAGER_NONE);
+                	fetch.traverseJDBC(fms[i]), fetch.EAGER_NONE);
 
                 // don't upgrade seld to > 0 based on these fields, since
                 // they're not in the calculated field set
@@ -1098,13 +1077,12 @@
      * case as an optimization.
      */
     private boolean optSelect(FieldMapping fm, Select sel,
-        OpenJPAStateManager sm, JDBCFetchState fetchState) {
+        OpenJPAStateManager sm, JDBCFetchConfiguration fetch) {
         return !fm.isDefaultFetchGroupExplicit()
-            && (sm == null || sm.getPCState() == PCState.TRANSIENT || !sm
-                .getLoaded().get(fm.getIndex()))
-            && fm.supportsSelect(sel, sel.TYPE_TWO_PART, sm, this,
-                getFetchConfiguration(fetchState)) > 0
-            && fetchState.requiresFetch(fm);
+            && (sm == null || sm.getPCState() == PCState.TRANSIENT 
+            || !sm.getLoaded().get(fm.getIndex()))
+            && fm.supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, fetch) > 0
+            && fetch.requiresFetch(fm);
     }
 
     /**
@@ -1117,9 +1095,8 @@
      * @param fetch the fetch configuration
      */
     private void selectSubclassMappings(Select sel, ClassMapping mapping,
-        OpenJPAStateManager sm, JDBCFetchState fetchState) {
+        OpenJPAStateManager sm, JDBCFetchConfiguration fetch) {
         loadSubclasses(mapping);
-        JDBCFetchConfiguration fetch = getFetchConfiguration(fetchState);
         ClassMapping[] subMappings = mapping.getJoinablePCSubclassMappings();
         if (subMappings.length == 0)
             return;
@@ -1145,15 +1122,10 @@
             fms = subMappings[i].getDefinedFieldMappings();
             for (int j = 0; j < fms.length; j++) {
                 // make sure in one of configured fetch groups
-            	if (fetchState.requiresFetch(fms[j]) 
-            	  || fms[j].supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, fetch) <= 0) 
+            	if (fetch.requiresFetch(fms[j]) 
+            	  || fms[j].supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, 
+                    fetch) <= 0) 
             		continue;
-//                if (!fms[j].isInDefaultFetchGroup()
-//                    && !fetch.hasAnyFetchGroup(fms[j].getFetchGroups())
-//                    && !fetch.hasField(fms[j].getFullName())
-//                    && (fms[j].isDefaultFetchGroupExplicit() || fms[j]
-//                        .supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, fetch) <= 0))
-//                    continue;
 
                 // if we can join to the subclass, do so; much better chance
                 // that the field will be able to select itself without joins
@@ -1166,10 +1138,10 @@
 
                 // if can select with tables already selected, do it
                 if (fms[j].supportsSelect(sel, sel.TYPE_JOINLESS, sm, this,
-                    fetch) > 0 && fetchState.requiresFetch(fms[j]))
-                    fms[j].select(sel, null, this, 
-                        	(JDBCFetchState)fetchState.traverse(fms[j]), 
-                        	fetch.EAGER_NONE);
+                    fetch) > 0 && fetch.requiresFetch(fms[j])) {
+                    fms[j].select(sel, null, this, fetch.traverseJDBC (fms[j]),
+                        fetch.EAGER_NONE);
+                }
             }
         }
     }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreQuery.java Fri Jul 28 16:48:13 2006
@@ -136,9 +136,8 @@
                 .get("mult-mapping-aggregate", Arrays.asList(metas)));
 
         ClassMapping[] mappings = (ClassMapping[]) metas;
-        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
-            .getFetchConfiguration();
-        JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
+        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) 
+            ctx.getFetchConfiguration();
         if (exps[0].fetchPaths != null) {
             fetch.addFields(Arrays.asList(exps[0].fetchPaths));
             fetch.addJoins(Arrays.asList(exps[0].fetchPaths));
@@ -147,8 +146,8 @@
         int eager = calculateEagerMode(exps[0], startIdx, endIdx);
         int subclassMode = fetch.getSubclassFetchMode((ClassMapping) base);
         DBDictionary dict = _store.getDBDictionary();
-        long start = (mappings.length == 1 && dict.supportsSelectStartIndex) ? startIdx
-            : 0L;
+        long start = (mappings.length == 1 && dict.supportsSelectStartIndex) 
+            ? startIdx : 0L;
         long end = (dict.supportsSelectEndIndex) ? endIdx : Long.MAX_VALUE;
 
         // add selects with populate WHERE conditions to list
@@ -158,7 +157,7 @@
         BitSet nextBits = new BitSet();
         boolean unionable = createWhereSelects(sels, mappings, selMappings,
             subclasses, subclassBits, nextBits, facts, exps, params,
-            fetchState, subclassMode)
+            fetch, subclassMode)
             && subclassMode == JDBCFetchConfiguration.EAGER_JOIN
             && start == 0
             && end == Long.MAX_VALUE;
@@ -166,8 +165,8 @@
         // we might want to use lrs settings if we can't use the range
         if (sels.size() > 1)
             start = 0L;
-        lrs = lrs
-            || (fetch.getFetchBatchSize() >= 0 && (start != startIdx || end != endIdx));
+        lrs = lrs || (fetch.getFetchBatchSize() >= 0 && (start != startIdx 
+            || end != endIdx));
 
         ResultObjectProvider[] rops = null;
         ResultObjectProvider rop = null;
@@ -175,9 +174,9 @@
             Union union = _store.getSQLFactory().newUnion(
                 (Select[]) sels.toArray(new Select[sels.size()]));
             BitSet[] paged = populateUnion(union, mappings, subclasses, facts,
-                exps, params, fetchState, lrs, eager, start, end);
+                exps, params, fetch, lrs, eager, start, end);
             union.setLRS(lrs);
-            rop = executeUnion(union, mappings, exps, paged, fetchState);
+            rop = executeUnion(union, mappings, exps, paged, fetch);
         } else {
             if (sels.size() > 1)
                 rops = new ResultObjectProvider[sels.size()];
@@ -188,10 +187,10 @@
                 sel = (Select) sels.get(i);
                 paged = populateSelect(sel, (ClassMapping) selMappings.get(i),
                     subclassBits.get(i), (JDBCExpressionFactory) facts[idx],
-                    exps[idx], params, fetchState, lrs, eager, start, end);
+                    exps[idx], params, fetch, lrs, eager, start, end);
 
                 rop = executeSelect(sel, (ClassMapping) selMappings.get(i),
-                    exps[idx], paged, fetchState, start, end);
+                    exps[idx], paged, fetch, start, end);
                 if (rops != null)
                     rops[i] = rop;
 
@@ -222,7 +221,7 @@
     private BitSet[] populateUnion(Union union, final ClassMapping[] mappings,
         final boolean subclasses, final ExpressionFactory[] facts,
         final QueryExpressions[] exps, final Object[] params,
-        final JDBCFetchState fetchState, final boolean lrs, final int eager,
+        final JDBCFetchConfiguration fetch, final boolean lrs, final int eager,
         final long start, final long end) {
         final BitSet[] paged = (exps[0].projections.length > 0) ? null
             : new BitSet[mappings.length];
@@ -231,7 +230,7 @@
             public void select(Select sel, int idx) {
                 BitSet bits = populateSelect(sel, mappings[idx], subclasses,
                     (JDBCExpressionFactory) facts[idx], exps[idx], params,
-                    fetchState, lrs, eager, start, end);
+                    fetch, lrs, eager, start, end);
                 if (paged != null)
                     paged[idx] = bits;
             }
@@ -244,7 +243,7 @@
      */
     private BitSet populateSelect(Select sel, ClassMapping mapping,
         boolean subclasses, JDBCExpressionFactory fact, QueryExpressions exps,
-        Object[] params, JDBCFetchState fetchState, boolean lrs, int eager,
+        Object[] params, JDBCFetchConfiguration fetch, boolean lrs, int eager,
         long start, long end) {
         sel.setLRS(lrs);
         sel.setRange(start, end);
@@ -252,12 +251,12 @@
         BitSet paged = null;
         if (exps.projections.length == 0) {
             paged = PagingResultObjectProvider.getPagedFields(sel, mapping,
-                _store, fetchState, eager, end - start);
+                _store, fetch, eager, end - start);
             if (paged != null)
                 eager = JDBCFetchConfiguration.EAGER_JOIN;
         }
 
-        fact.select(this, mapping, subclasses, sel, exps, params, fetchState,
+        fact.select(this, mapping, subclasses, sel, exps, params, fetch,
             eager);
         return paged;
     }
@@ -267,19 +266,19 @@
      */
     private ResultObjectProvider executeUnion(Union union,
         ClassMapping[] mappings, QueryExpressions[] exps, BitSet[] paged,
-        JDBCFetchState fetchState) {
+        JDBCFetchConfiguration fetch) {
         if (exps[0].projections.length > 0)
             return new ProjectionResultObjectProvider(union, _store,
-                fetchState, exps);
+                fetch, exps);
 
         if (paged != null)
             for (int i = 0; i < paged.length; i++)
                 if (paged[i] != null)
                     return new PagingResultObjectProvider(union, mappings,
-                        _store, fetchState, paged, Long.MAX_VALUE);
+                        _store, fetch, paged, Long.MAX_VALUE);
 
         return new InstanceResultObjectProvider(union, mappings[0], _store,
-            fetchState);
+            fetch);
     }
 
     /**
@@ -287,15 +286,13 @@
      */
     private ResultObjectProvider executeSelect(Select sel,
         ClassMapping mapping, QueryExpressions exps, BitSet paged,
-        JDBCFetchState fetchState, long start, long end) {
+        JDBCFetchConfiguration fetch, long start, long end) {
         if (exps.projections.length > 0)
-            return new ProjectionResultObjectProvider(sel, _store, fetchState,
-                exps);
+            return new ProjectionResultObjectProvider(sel, _store, fetch, exps);
         if (paged != null)
-            return new PagingResultObjectProvider(sel, mapping, _store,
-                fetchState, paged, end - start);
-        return new InstanceResultObjectProvider(sel, mapping, _store,
-            fetchState);
+            return new PagingResultObjectProvider(sel, mapping, _store, fetch, 
+                paged, end - start);
+        return new InstanceResultObjectProvider(sel, mapping, _store, fetch);
     }
 
     /**
@@ -305,7 +302,7 @@
     private boolean createWhereSelects(List sels, ClassMapping[] mappings,
         List selMappings, boolean subclasses, BitSet subclassBits,
         BitSet nextBits, ExpressionFactory[] facts, QueryExpressions[] exps,
-        Object[] params, JDBCFetchState fetchState, int subclassMode) {
+        Object[] params, JDBCFetchConfiguration fetch, int subclassMode) {
         Select sel;
         ClassMapping[] verts;
         boolean unionable = true;
@@ -317,7 +314,7 @@
                 subclassBits.set(sels.size());
 
             // create criteria select and clone for each vert mapping
-            sel = ((JDBCExpressionFactory) facts[i]).evaluate(this, fetchState,
+            sel = ((JDBCExpressionFactory) facts[i]).evaluate(this, fetch,
                 exps[i], params);
             for (int j = 0; j < verts.length; j++) {
                 selMappings.add(verts[j]);
@@ -439,8 +436,8 @@
             }
         }
 
-        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
-            .getFetchConfiguration();
+        JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) 
+            ctx.getFetchConfiguration();
         DBDictionary dict = _store.getDBDictionary();
 
         SQLBuffer[] sql = new SQLBuffer[mappings.length];
@@ -448,10 +445,9 @@
         Select sel;
         for (int i = 0; i < mappings.length; i++) {
             jdbcFactory = (JDBCExpressionFactory) facts[i];
-            JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
-            sel = jdbcFactory.evaluate(this, fetchState, exps[i], params);
+            sel = jdbcFactory.evaluate(this, fetch, exps[i], params);
             jdbcFactory.select(this, mappings[i], subclasses, sel, exps[i],
-                params, fetchState, JDBCFetchConfiguration.EAGER_NONE);
+                params, fetch, JDBCFetchConfiguration.EAGER_NONE);
 
             // specification of the "udpates" map indicates that this is
             // an update query; otherwise, this is a delete statement
@@ -580,7 +576,6 @@
         ClassMapping[] mappings = (ClassMapping[]) metas;
         JDBCFetchConfiguration fetch = (JDBCFetchConfiguration) ctx
             .getFetchConfiguration();
-        JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
         if (exps[0].fetchPaths != null) {
             fetch.addFields(Arrays.asList(exps[0].fetchPaths));
             fetch.addJoins(Arrays.asList(exps[0].fetchPaths));
@@ -590,8 +585,8 @@
         eager = Math.min(eager, JDBCFetchConfiguration.EAGER_JOIN);
         int subclassMode = fetch.getSubclassFetchMode((ClassMapping) base);
         DBDictionary dict = _store.getDBDictionary();
-        long start = (mappings.length == 1 && dict.supportsSelectStartIndex) ? startIdx
-            : 0L;
+        long start = (mappings.length == 1 && dict.supportsSelectStartIndex) 
+            ? startIdx : 0L;
         long end = (dict.supportsSelectEndIndex) ? endIdx : Long.MAX_VALUE;
 
         // add selects with populate WHERE conditions to list
@@ -600,9 +595,8 @@
         BitSet subclassBits = new BitSet();
         BitSet nextBits = new BitSet();
         boolean unionable = createWhereSelects(sels, mappings, selMappings,
-            subclasses, subclassBits, nextBits, facts, exps, params,
-            fetchState, subclassMode)
-            && subclassMode == JDBCFetchConfiguration.EAGER_JOIN;
+            subclasses, subclassBits, nextBits, facts, exps, params, fetch, 
+            subclassMode) && subclassMode == JDBCFetchConfiguration.EAGER_JOIN;
         if (sels.size() > 1)
             start = 0L;
 
@@ -610,9 +604,9 @@
             Union union = _store.getSQLFactory().newUnion(
                 (Select[]) sels.toArray(new Select[sels.size()]));
             populateUnion(union, mappings, subclasses, facts, exps, params,
-                fetchState, false, eager, start, end);
+                fetch, false, eager, start, end);
             if (union.isUnion())
-                return new String[] { union.toSelect(false, fetch).getSQL(true) };
+                return new String[] {union.toSelect(false, fetch).getSQL(true)};
             sels = Arrays.asList(union.getSelects());
         } else {
             Select sel;
@@ -620,7 +614,7 @@
                 sel = (Select) sels.get(i);
                 populateSelect(sel, (ClassMapping) selMappings.get(i),
                     subclassBits.get(i), (JDBCExpressionFactory) facts[idx],
-                    exps[idx], params, fetchState, false, eager, start, end);
+                    exps[idx], params, fetch, false, eager, start, end);
                 if (nextBits.get(i))
                     idx++;
             }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MappedQueryResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MappedQueryResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MappedQueryResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MappedQueryResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -92,14 +92,12 @@
         if (pcs.length == 0 && cols.length == 1)
             return _mres.getObject(cols[0], JavaSQLTypes.JDBC_DEFAULT, null);
         if (pcs.length == 1 && cols.length == 0)
-            return _mres.load(pcs[0], _store,
-                (JDBCFetchState) _fetch.newFetchState());
+            return _mres.load(pcs[0], _store, _fetch);
 
         // multiple objects
         Object[] ret = new Object[pcs.length + cols.length];
         for (int i = 0; i < pcs.length; i++)
-            ret[i] = _mres.load(pcs[i], _store,
-                (JDBCFetchState) _fetch.newFetchState());
+            ret[i] = _mres.load(pcs[i], _store, _fetch);
         for (int i = 0; i < cols.length; i++)
             ret[pcs.length + i] = _mres.getObject(cols[i],
                 JavaSQLTypes.JDBC_DEFAULT, null);
@@ -162,31 +160,31 @@
          * {@link Result#load}.
          */
         public Object load(QueryResultMapping.PCResult pc, JDBCStore store,
-            JDBCFetchState fetchState)
+            JDBCFetchConfiguration fetch)
             throws SQLException {
             _pc = pc;
             try {
-                return load(pc.getCandidateTypeMapping(), store, fetchState);
+                return load(pc.getCandidateTypeMapping(), store, fetch);
             } finally {
                 _pc = null;
             }
         }
 
         public Object load(ClassMapping mapping, JDBCStore store,
-            JDBCFetchState fetchState)
+            JDBCFetchConfiguration fetch)
             throws SQLException {
-            return load(mapping, store, fetchState, null);
+            return load(mapping, store, fetch, null);
         }
 
         public Object load(ClassMapping mapping, JDBCStore store,
-            JDBCFetchState fetchState, Joins joins)
+            JDBCFetchConfiguration fetch, Joins joins)
             throws SQLException {
             if (_pc == null)
-                return super.load(mapping, store, fetchState, joins);
+                return super.load(mapping, store, fetch, joins);
 
             // we go direct to the store manager so we can tell it not to load
             // anything additional
-            return ((JDBCStoreManager) store).load(mapping, fetchState,
+            return ((JDBCStoreManager) store).load(mapping, fetch,
                 _pc.getExcludes(_requests), this);
         }
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PagingResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -67,16 +67,14 @@
      * @see #PagingResultObjectProvider
      */
     public static BitSet getPagedFields(Select sel, ClassMapping mapping,
-        JDBCStore store, JDBCFetchState fetchState, int eagerMode,
+        JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode,
         long size) {
-        JDBCFetchConfiguration fetch = fetchState.getJDBCFetchConfiguration();
         // if we have a range then we always use paging if there are any
         // eager select fields; otherwise it depends on lrs and fetch settings
         if (size == Long.MAX_VALUE || !sel.getAutoDistinct()) {
             // not lrs?
             if (!sel.isLRS())
                 return null;
-
             // not configured for lazy loading?
             if (fetch.getFetchBatchSize() < 0)
                 return null;
@@ -91,8 +89,7 @@
         FieldMapping[] fms = mapping.getDefinedFieldMappings();
         BitSet paged = null;
         for (int i = 0; i < fms.length; i++) {
-            if (fetchState != null
-                && !fetchState.requiresFetch(fms[i]))
+            if (!fetch.requiresFetch(fms[i]))
                 continue;
 
             if (fms[i].supportsSelect(sel, sel.EAGER_PARALLEL, null, store,
@@ -119,9 +116,9 @@
      * {@link Long#MAX_VALUE} for no known limit
      */
     public PagingResultObjectProvider(SelectExecutor sel,
-        ClassMapping mapping, JDBCStore store, JDBCFetchState fetchState,
+        ClassMapping mapping, JDBCStore store, JDBCFetchConfiguration fetch,
         BitSet paged, long size) {
-        this(sel, new ClassMapping[]{ mapping }, store, fetchState,
+        this(sel, new ClassMapping[]{ mapping }, store, fetch,
             new BitSet[]{ paged }, size);
     }
 
@@ -139,9 +136,9 @@
      * {@link Long#MAX_VALUE} for no known limit
      */
     public PagingResultObjectProvider(SelectExecutor sel,
-        ClassMapping[] mappings, JDBCStore store, JDBCFetchState fetchState,
+        ClassMapping[] mappings, JDBCStore store, JDBCFetchConfiguration fetch,
         BitSet[] paged, long size) {
-        super(sel, store, fetchState);
+        super(sel, store, fetch);
         _mappings = mappings;
         _paged = paged;
 
@@ -255,7 +252,7 @@
             // rather than use the standard result.load(), we go direct to
             // the store manager so we can pass in our eager-fetched fields as
             // fields to exclude from the initial load of the objects
-            _page[i] = storeMgr.load(mapping, getFetchState(),
+            _page[i] = storeMgr.load(mapping, getFetchConfiguration(),
                 _paged[idx], res);
             if (i != _page.length - 1 && !getResult().next()) {
                 setSize(_pos + i + 1);
@@ -287,7 +284,7 @@
         for (int i = 0, len = _paged[idx].length(); i < len; i++) {
             if (_paged[idx].get(i)) {
                 _mappings[idx].getFieldMapping(i).load(sm, store,
-                    getFetchState());
+                    getFetchConfiguration());
             }
         }
     }
@@ -354,7 +351,6 @@
 
         StoreContext ctx = store.getContext();
         JDBCFetchConfiguration fetch = getFetchConfiguration();
-        JDBCFetchState fetchState = (JDBCFetchState) fetch.newFetchState();
         // do each batch select
         Object res;
         int esels = 0;
@@ -377,14 +373,14 @@
                 esel = sel;
 
             // get result
-            fms[i].selectEagerParallel(esel, null, store, fetchState,
+            fms[i].selectEagerParallel(esel, null, store, fetch,
                 JDBCFetchConfiguration.EAGER_PARALLEL);
             res = esel.execute(store, fetch);
             try {
                 // and load result into paged instances
                 for (int j = start; j < end && _page[j] != null; j++)
                     res = fms[i].loadEagerParallel(ctx.getStateManager
-                        (_page[j]), store, fetchState, res);
+                        (_page[j]), store, fetch, res);
             } finally {
                 if (res instanceof Closeable)
                     try {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ProjectionResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -39,8 +39,8 @@
      * @param exps the query expressions
      */
     public ProjectionResultObjectProvider(SelectExecutor sel, JDBCStore store,
-        JDBCFetchState fetchState, QueryExpressions exps) {
-        this(sel, store, fetchState, new QueryExpressions[]{ exps });
+        JDBCFetchConfiguration fetch, QueryExpressions exps) {
+        this(sel, store, fetch, new QueryExpressions[]{ exps });
     }
 
     /**
@@ -52,8 +52,8 @@
      * @param exps the query expressions
      */
     public ProjectionResultObjectProvider(SelectExecutor sel, JDBCStore store,
-        JDBCFetchState fetchState, QueryExpressions[] exps) {
-        super(sel, store, fetchState);
+        JDBCFetchConfiguration fetch, QueryExpressions[] exps) {
+        super(sel, store, fetch);
         _exps = exps;
     }
 
@@ -64,7 +64,7 @@
         Object[] arr = new Object[_exps[idx].projections.length];
         for (int i = 0; i < _exps[idx].projections.length; i++)
             arr[i] = ((Val) _exps[idx].projections[i]).load(res, getStore(),
-                getFetchState());
+                getFetchConfiguration());
         return arr;
     }
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SelectResultObjectProvider.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SelectResultObjectProvider.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SelectResultObjectProvider.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/SelectResultObjectProvider.java Fri Jul 28 16:48:13 2006
@@ -36,7 +36,6 @@
     private final SelectExecutor _sel;
     private final JDBCStore _store;
     private final JDBCFetchConfiguration _fetch;
-    private final JDBCFetchState _fetchState;
     private Result _res = null;
     private int _size = -1;
     private Boolean _ra = null;
@@ -49,15 +48,10 @@
      * @param fetch the fetch configuration, or null for the default
      */
     public SelectResultObjectProvider(SelectExecutor sel, JDBCStore store,
-        JDBCFetchState fetchState) {
+        JDBCFetchConfiguration fetch) {
         _sel = sel;
         _store = store;
-//		if (fetch == null)
-//			_fetch = store.getFetchConfiguration ();
-//		else
-//			_fetch = fetch;
-        _fetchState = fetchState;
-        _fetch = fetchState.getJDBCFetchConfiguration();
+        _fetch = fetch;
     }
 
     public SelectExecutor getSelect() {
@@ -70,10 +64,6 @@
 
     public JDBCFetchConfiguration getFetchConfiguration() {
         return _fetch;
-    }
-
-    public JDBCFetchState getFetchState() {
-        return _fetchState;
     }
 
     public Result getResult() {

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AbstractVal.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AbstractVal.java?rev=426710&r1=426709&r2=426710&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AbstractVal.java (original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/AbstractVal.java Fri Jul 28 16:48:13 2006
@@ -15,7 +15,7 @@
  */
 package org.apache.openjpa.jdbc.kernel.exps;
 
-import org.apache.openjpa.jdbc.kernel.JDBCFetchState;
+import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
 import org.apache.openjpa.jdbc.sql.Select;
@@ -32,29 +32,29 @@
     private static final String FALSE = "1 <> 1";
 
     public void appendIsEmpty(SQLBuffer sql, Select sel, JDBCStore store,
-        Object[] params, JDBCFetchState fetchState) {
+        Object[] params, JDBCFetchConfiguration fetch) {
         sql.append(FALSE);
     }
 
     public void appendIsNotEmpty(SQLBuffer sql, Select sel, JDBCStore store,
-        Object[] params, JDBCFetchState fetchState) {
+        Object[] params, JDBCFetchConfiguration fetch) {
         sql.append(TRUE);
     }
 
     public void appendIsNull(SQLBuffer sql, Select sel,
-        JDBCStore store, Object[] params, JDBCFetchState fetchState) {
-        appendTo(sql, 0, sel, store, params, fetchState);
+        JDBCStore store, Object[] params, JDBCFetchConfiguration fetch) {
+        appendTo(sql, 0, sel, store, params, fetch);
         sql.append(" IS ").appendValue(null);
     }
 
     public void appendIsNotNull(SQLBuffer sql, Select sel,
-        JDBCStore store, Object[] params, JDBCFetchState fetchState) {
-        appendTo(sql, 0, sel, store, params, fetchState);
+        JDBCStore store, Object[] params, JDBCFetchConfiguration fetch) {
+        appendTo(sql, 0, sel, store, params, fetch);
         sql.append(" IS NOT ").appendValue(null);
     }
 
     public void appendSize(SQLBuffer sql, Select sel, JDBCStore store,
-        Object[] params, JDBCFetchState fetchState) {
+        Object[] params, JDBCFetchConfiguration fetch) {
         sql.append("1");
     }
 }



Mime
View raw message