openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r1243702 [2/5] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/...
Date Mon, 13 Feb 2012 21:23:56 GMT
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java Mon Feb 13 21:23:54 2012
@@ -31,7 +31,6 @@ import java.util.concurrent.ConcurrentHa
 
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.enhance.Reflection;
-import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.strats.NoneClassStrategy;
@@ -45,8 +44,6 @@ import org.apache.openjpa.jdbc.sql.Joins
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.RowManager;
 import org.apache.openjpa.jdbc.sql.Select;
-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.OpenJPAStateManager;
 import org.apache.openjpa.kernel.PCState;
@@ -63,22 +60,17 @@ import org.apache.openjpa.util.OpenJPAId
 
 /**
  * Specialization of metadata for relational databases.
- * <br>
- * The mapping may reuse the same {@link SelectExecutor select} if the 
- * {@link JDBCConfiguration#getSelectCacheEnabled() configuration option}
- * instructs to do so. 
  *
  * @author Abe White
- * @author Pinaki Poddar (select caching)
  */
-@SuppressWarnings("serial")
 public class ClassMapping
     extends ClassMetaData
     implements ClassStrategy {
 
     public static final ClassMapping[] EMPTY_MAPPINGS = new ClassMapping[0];
 
-    private static final Localizer _loc = Localizer.forPackage(ClassMapping.class);
+    private static final Localizer _loc = Localizer.forPackage
+        (ClassMapping.class);
 
     private final ClassMappingInfo _info;
     private final Discriminator _discrim;
@@ -96,9 +88,6 @@ public class ClassMapping
 
     // maps columns to joinables
     private final Map _joinables = new ConcurrentHashMap();
-    
-    private Select _select;
-    private Union  _union;
 
     /**
      * Constructor. Supply described type and owning repository.
@@ -1120,48 +1109,4 @@ public class ClassMapping
             return true;
         return false;
     }
-    
-    /**
-     * Gets the {@link Select select} used for selecting instances of this mapping.
-     * If {@link JDBCConfiguration#getSelectCacheEnabled() aggressive caching} of
-     * select statements is enabled, then a select is generated for the first call,
-     * cached in this mapping and subsequently returned. A cached select becomes 
-     * {@link Select#isReadOnly() immutable} i.e. no structural modification is
-     * allowed <em>after</em> its corresponding SQL has been executed on the database.
-     * 
-     * @return a new or cached select to select instances of this mapping.  
-     */
-    public Select getSelect() {
-    	Select result = _select;
-    	if (result == null) {
-    		JDBCConfiguration conf = (JDBCConfiguration)getMappingRepository().getConfiguration();
-    		result = conf.getSQLFactoryInstance().newSelect();
-    		if (conf.getSelectCacheEnabled()) {
-    			_select = result;
-    		}
-    	}
-    	return result;
-    }
-    
-    /**
-     * Gets the {@link Union union} used for selecting instances of this mapping.
-     * If {@link JDBCConfiguration#getSelectCacheEnabled() aggressive caching} of
-     * union statements is enabled, then a union is generated for the first call,
-     * cached in this mapping and subsequently returned. A cached union becomes 
-     * {@link Select#isReadOnly() immutable} i.e. no structural modification is
-     * allowed <em>after</em> its corresponding SQL has been executed on the database.
-     * 
-     * @return a new or cached union to select instances of this mapping.  
-     */
-    public Union getUnion(int selects) {
-    	Union result = _union;
-    	if (result == null) {
-    		JDBCConfiguration conf = (JDBCConfiguration)getMappingRepository().getConfiguration();
-    		result = conf.getSQLFactoryInstance().newUnion(selects);
-    		if (conf.getSelectCacheEnabled()) {
-    			_union = result;
-    		}
-    	}
-    	return result;
-    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java Mon Feb 13 21:23:54 2012
@@ -81,19 +81,19 @@ public class FieldMapping
     private boolean _outer = false;
     private int _fetchMode = Integer.MAX_VALUE;
     private Unique[] _joinTableUniques; // Unique constraints on JoinTable
-    private Boolean _bidirectionalJoinTableOwner;
-    private Boolean _bidirectionalJoinTableNonOwner;
+    private Boolean _bidirectionalJoinTableOwner = null;
+    private Boolean _bidirectionalJoinTableNonOwner = null;
     
-    private Boolean _bidirectionalManyToOneJoinTable;
-    private Boolean _unidirectionalOneToManyForeignKey;
-    private Boolean _unidirectionalManyToOneJoinTable;
-    private Boolean _unidirectionalOneToOneJoinTable;
-    private Boolean _bidirectionalOneToOneJoinTable;
+    private Boolean _bi_MTo1_JT = null;
+    private Boolean _uni_1ToM_FK = null;
+    private Boolean _uni_MTo1_JT = null;
+    private Boolean _uni_1To1_JT = null;
+    private Boolean _bi_1To1_JT = null;
     
-    private FieldMapping _bidirectionalOneToManyJoinTableField;
-    private FieldMapping _bidirectionalManyToOneJoinTableField;
-    private ForeignKey _bidirectionalOneToManyJoinForeignKey;
-    private ForeignKey _bidirectionalOneToManyElementForeignKey;
+    private FieldMapping _bi_1ToM_JT_Field = null;
+    private FieldMapping _bi_MTo1_JT_Field = null;
+    private ForeignKey _bi_1ToM_Join_FK = null;
+    private ForeignKey _bi_1ToM_Elem_FK = null;
     
     private boolean _hasMapsIdCols = false;
         
@@ -1271,90 +1271,85 @@ public class FieldMapping
         return _bidirectionalJoinTableNonOwner.booleanValue();
     }
     
-    public boolean isBidirectionalManyToOneJoinTable() {
-        if (_bidirectionalManyToOneJoinTable == null) {
-            _bidirectionalManyToOneJoinTable = getMappingRepository().isBidirectionalManyToOneJoinTable(this);
+    public boolean isBiMTo1JT() {
+        if (_bi_MTo1_JT == null) {
+            _bi_MTo1_JT = getMappingRepository().isBiMTo1JT(this);
         }
-        return _bidirectionalManyToOneJoinTable;
+        return _bi_MTo1_JT;
     }
 
-    public boolean isUnidirectionalOneToManyForeignKey() {
-        if (_unidirectionalOneToManyForeignKey == null)
-            _unidirectionalOneToManyForeignKey = getMappingRepository().isUnidirectionalOneToManyForeignKey(this);
-        return _unidirectionalOneToManyForeignKey;
+    public boolean isUni1ToMFK() {
+        if (_uni_1ToM_FK == null)
+            _uni_1ToM_FK = getMappingRepository().isUni1ToMFK(this);
+        return _uni_1ToM_FK;
     }
     
-    public boolean isUnidirectionalManyToOneJoinTable() {
-        if (_unidirectionalManyToOneJoinTable == null)
-            _unidirectionalManyToOneJoinTable = getMappingRepository().isUnidirectionalManyToOneJoinTable(this);
-        return _unidirectionalManyToOneJoinTable;
-    }
-
-    public boolean isUnidirectionalOneToOneJoinTable() {
-        if (_unidirectionalOneToOneJoinTable == null)
-            _unidirectionalOneToOneJoinTable = getMappingRepository().isUnidirectionalOneToOneJoinTable(this);
-        return _unidirectionalOneToOneJoinTable;
-    }
-
-    public boolean isBidirectionalOneToOneJoinTable() {
-        if (_bidirectionalOneToOneJoinTable == null)
-            _bidirectionalOneToOneJoinTable = getMappingRepository().isBidirectionalOneToOneJoinTable(this);
-        return _bidirectionalOneToOneJoinTable;
+    public boolean isUniMTo1JT() {
+        if (_uni_MTo1_JT == null)
+            _uni_MTo1_JT = getMappingRepository().isUniMTo1JT(this);
+        return _uni_MTo1_JT;
+    }
+
+    public boolean isUni1To1JT() {
+        if (_uni_1To1_JT == null)
+            _uni_1To1_JT = getMappingRepository().isUni1To1JT(this);
+        return _uni_1To1_JT;
+    }
+
+    public boolean isBi1To1JT() {
+        if (_bi_1To1_JT == null)
+            _bi_1To1_JT = getMappingRepository().isBi1To1JT(this);
+        return _bi_1To1_JT;
     }
     
-    public FieldMapping getBidirectionalOneToManyJoinTableField() {
-        if (_bidirectionalOneToManyJoinTableField == null) {
-            _bidirectionalOneToManyJoinTableField = 
-            	getMappingRepository().getBidirectionalOneToManyJoinTableField(this);
+    public FieldMapping getBi_1ToM_JTField() {
+        if (_bi_1ToM_JT_Field == null) {
+            _bi_1ToM_JT_Field = getMappingRepository().getBi_1ToM_JoinTableField(this);
         }
-        return _bidirectionalOneToManyJoinTableField;
+        return _bi_1ToM_JT_Field;
     }
     
-    public FieldMapping getBidirectionalManyToOneJoinTableField() {
-        if (_bidirectionalManyToOneJoinTableField == null) {
-            _bidirectionalManyToOneJoinTableField = 
-            	getMappingRepository().getBidirectionalManyToOneJoinTableField(this);
+    public FieldMapping getBi_MTo1_JTField() {
+        if (_bi_MTo1_JT_Field == null) {
+            _bi_MTo1_JT_Field = getMappingRepository().getBi_MTo1_JoinTableField(this);
         }
-        return _bidirectionalManyToOneJoinTableField;
+        return _bi_MTo1_JT_Field;
     }
 
-    public ForeignKey getBidirectionalOneToManyJoinForeignKey() {
-        if (_bidirectionalOneToManyJoinForeignKey == null) {
-            getBidirectionalOneToManyJoinTableField();
-            if (_bidirectionalOneToManyJoinTableField != null)
-                _bidirectionalOneToManyJoinForeignKey = _bidirectionalOneToManyJoinTableField.getJoinForeignKey();
+    public ForeignKey getBi1ToMJoinFK() {
+        if (_bi_1ToM_Join_FK == null) {
+            getBi_1ToM_JTField();
+            if (_bi_1ToM_JT_Field != null)
+                _bi_1ToM_Join_FK = _bi_1ToM_JT_Field.getJoinForeignKey();
         }
-        return _bidirectionalOneToManyJoinForeignKey;
+        return _bi_1ToM_Join_FK;
     }
     
-    public ForeignKey getBidirectionalOneToManyElementForeignKey() {
-        if (_bidirectionalOneToManyElementForeignKey == null) {
-            getBidirectionalOneToManyJoinTableField();
-            if (_bidirectionalOneToManyJoinTableField != null)
-                _bidirectionalOneToManyElementForeignKey = 
-                	_bidirectionalOneToManyJoinTableField.getElementMapping().getForeignKey();
+    public ForeignKey getBi1ToMElemFK() {
+        if (_bi_1ToM_Elem_FK == null) {
+            getBi_1ToM_JTField();
+            if (_bi_1ToM_JT_Field != null)
+                _bi_1ToM_Elem_FK = _bi_1ToM_JT_Field.getElementMapping().getForeignKey();
         }
-        return _bidirectionalOneToManyElementForeignKey;
+        return _bi_1ToM_Elem_FK;
     }
     
-    public void setBidirectionalOneToManyJoinTableInfo() {
+    public void setBi1MJoinTableInfo() {
         if (getAssociationType() == FieldMetaData.ONE_TO_MANY) {
-            FieldMapping mapped = getBidirectionalManyToOneJoinTableField();
+            FieldMapping mapped = getBi_MTo1_JTField();
             if (mapped != null) {
                 FieldMappingInfo info = getMappingInfo();
                 FieldMappingInfo mappedInfo = mapped.getMappingInfo();
                 info.setTableIdentifier(mappedInfo.getTableIdentifier());
                 info.setColumns(mapped.getElementMapping().getValueInfo().getColumns());
-                getElementMapping().getValueInfo().setColumns(mappedInfo.getColumns());
+                getElementMapping().getValueInfo().setColumns(
+                    mappedInfo.getColumns());
             }
         }
     }
    
     public boolean isNonDefaultMappingUsingJoinTableStrategy() {
-        return isBidirectionalOneToOneJoinTable() 
-            || isUnidirectionalOneToOneJoinTable() 
-            || isUnidirectionalManyToOneJoinTable() 
-            || isBidirectionalManyToOneJoinTable();
+        return isBi1To1JT() || isUni1To1JT() || isUniMTo1JT() || isBiMTo1JT();
     }
     
     public void setMapsIdCols(boolean hasMapsIdCols) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMappingInfo.java Mon Feb 13 21:23:54 2012
@@ -165,7 +165,7 @@ public class FieldMappingInfo
 
     public ForeignKey getJoinForeignKey (final FieldMapping field, Table table,
         boolean adapt) {
-        if (field.isUnidirectionalOneToManyForeignKey()) {
+        if (field.isUni1ToMFK()) {
             List<Column> cols = field.getElementMapping().getValueInfo().getColumns();
             return getJoin(field, table, adapt, cols);
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java Mon Feb 13 21:23:54 2012
@@ -105,14 +105,15 @@ import org.apache.openjpa.util.UserExcep
  *
  * @author Abe White
  */
-@SuppressWarnings("serial")
 public class MappingRepository extends MetaDataRepository {
 
-    private static final Localizer _loc = Localizer.forPackage(MappingRepository.class);
+    private static final Localizer _loc = Localizer.forPackage
+        (MappingRepository.class);
 
     private transient DBDictionary _dict = null;
     private transient MappingDefaults _defaults = null;
     
+    // object->queryresultmapping
     private Map<Object, QueryResultMapping> _results = new HashMap<Object, QueryResultMapping>(); 
     private SchemaGroup _schema = null;
     private StrategyInstaller _installer = null;
@@ -259,10 +260,12 @@ public class MappingRepository extends M
     public QueryResultMapping[] getQueryResultMappings() {
         if (_locking) {
             synchronized (this) {
-                return _results.values().toArray(new QueryResultMapping[_results.size()]);
+                Collection values = _results.values();
+                return (QueryResultMapping[]) values.toArray(new QueryResultMapping[values.size()]);
             }
         } else {
-            return _results.values().toArray(new QueryResultMapping[_results.size()]);
+            Collection values = _results.values();
+            return (QueryResultMapping[]) values.toArray(new QueryResultMapping[values.size()]);
         }
     }
 
@@ -270,7 +273,7 @@ public class MappingRepository extends M
      * Return the cached query result mapping with the given name, or null if
      * none.
      */
-    public QueryResultMapping getCachedQueryResultMapping(Class<?> cls, String name) {
+    public QueryResultMapping getCachedQueryResultMapping(Class cls, String name) {
         if (_locking) {
             synchronized (this) {
                 return (QueryResultMapping) _results.get(getQueryResultKey(cls, name));
@@ -283,7 +286,7 @@ public class MappingRepository extends M
     /**
      * Add a query result mapping.
      */
-    public QueryResultMapping addQueryResultMapping(Class<?> cls, String name) {
+    public QueryResultMapping addQueryResultMapping(Class cls, String name) {
         if (_locking) {
             synchronized (this) {
                 return addQueryResultMappingInternal(cls, name);
@@ -293,7 +296,7 @@ public class MappingRepository extends M
         }
     }
 
-    private QueryResultMapping addQueryResultMappingInternal(Class<?> cls, String name) {
+    private QueryResultMapping addQueryResultMappingInternal(Class cls, String name) {
         QueryResultMapping res = new QueryResultMapping(name, this);
         res.setDefiningType(cls);
         _results.put(getQueryResultKey(res), res);
@@ -316,7 +319,7 @@ public class MappingRepository extends M
     /**
      * Remove a query result mapping.
      */
-    public boolean removeQueryResultMapping(Class<?> cls, String name) {
+    public boolean removeQueryResultMapping(Class cls, String name) {
         if (_locking) {
             synchronized (this) {
                 if (name == null)
@@ -1005,7 +1008,8 @@ public class MappingRepository extends M
     protected FieldStrategy handlerCollectionStrategy(FieldMapping field, 
         ValueHandler ehandler, boolean installHandlers) {
         // TODO: JPA 2.0 should ignore this flag and not to serialize
-        if (getConfiguration().getCompatibilityInstance().getStoreMapCollectionInEntityAsBlob())
+        if (getConfiguration().getCompatibilityInstance()
+            .getStoreMapCollectionInEntityAsBlob())
             return null;
         if (installHandlers)
             field.getElementMapping().setHandler(ehandler);
@@ -1020,7 +1024,8 @@ public class MappingRepository extends M
         ValueHandler khandler, ValueHandler vhandler, boolean krel, 
         boolean vrel,  boolean installHandlers) {
         // TODO: JPA 2.0 should ignore this flag and not to serialize
-        if (getConfiguration().getCompatibilityInstance().getStoreMapCollectionInEntityAsBlob())
+        if (getConfiguration().getCompatibilityInstance()
+            .getStoreMapCollectionInEntityAsBlob())
             return null;
         if (installHandlers) {
             field.getKeyMapping().setHandler(khandler);
@@ -1043,13 +1048,14 @@ public class MappingRepository extends M
         FieldMapping mapped = field.getMappedByMapping();
         if (mapped != null) {
             //bi-/M-1/JoinTable ==> join table strategy
-            if (isBidirectionalManyToOneJoinTable(field)) 
+            if (isBiMTo1JT(field)) 
                 return false;
             if (mapped.getTypeCode() == JavaTypes.PC || mapped.getTypeCode() == JavaTypes.PC_UNTYPED)
                 return true;
             if (mapped.getElement().getTypeCode() == JavaTypes.PC)
                 return false;
-            throw new MetaDataException(_loc.get("bad-mapped-by", field, mapped));
+            throw new MetaDataException(_loc.get("bad-mapped-by", field,
+                mapped));
         }
 
         // without a mapped-by, we have to look for clues as to the mapping.
@@ -1058,84 +1064,82 @@ public class MappingRepository extends M
         // an association table
         FieldMappingInfo info = field.getMappingInfo();
         ValueMapping elem = field.getElementMapping();
-        boolean useInverseKeyMapping = DBIdentifier.isNull(info.getTableIdentifier()) 
-                                    && info.getColumns().isEmpty()
-                                    && !elem.getValueInfo().getColumns().isEmpty();
+        boolean useInverseKeyMapping = DBIdentifier.isNull(info.getTableIdentifier()) && info.getColumns().isEmpty()
+            && !elem.getValueInfo().getColumns().isEmpty();
         
         // JPA 2.0: non-default mapping: uni-/1-M/JoinColumn ==> foreign key strategy
-        if (isUnidirectionalOneToManyForeignKey(field)) {
+        if (isUni1ToMFK(field)) {
             return true;
         }
         return useInverseKeyMapping;
     }
         
     public boolean isNonDefaultMappingAllowed() {
-        return getMetaDataFactory().getDefaults().isNonDefaultMappingAllowed(getConfiguration());
+        OpenJPAConfiguration conf = getConfiguration();
+        return getMetaDataFactory().getDefaults().isNonDefaultMappingAllowed(conf);
     }
     
-    public boolean isUnidirectionalManyToOneJoinTable(FieldMapping field) {
-        if (isNonDefaultMappingAllowed() 
-         && field.getAssociationType() == FieldMetaData.MANY_TO_ONE 
-         && hasJoinTable(field) 
-         && !isBidirectional(field))  {
+    public boolean isUniMTo1JT(FieldMapping field) {
+        if (isNonDefaultMappingAllowed() && 
+            field.getAssociationType() == FieldMetaData.MANY_TO_ONE &&
+            hasJoinTable(field) && 
+            !isBidirectional(field))  {
             field.getValueMapping().getValueInfo().setColumns(field.getElementMapping().getValueInfo().getColumns());
             return true;
         }
         return false;
     }
 
-    public boolean isUnidirectionalOneToOneJoinTable(FieldMapping field) {
-        if (isNonDefaultMappingAllowed() 
-         && field.getAssociationType() == FieldMetaData.ONE_TO_ONE 
-         && hasJoinTable(field) 
-         && !isBidirectional(field)) {
+    public boolean isUni1To1JT(FieldMapping field) {
+        if (isNonDefaultMappingAllowed() && 
+            field.getAssociationType() == FieldMetaData.ONE_TO_ONE && 
+            hasJoinTable(field) && 
+            !isBidirectional(field)) {
             field.getValueMapping().getValueInfo().setColumns(field.getElementMapping().getValueInfo().getColumns());
             return true;
         }
         return false;
     }
 
-    public boolean isBidirectionalOneToOneJoinTable(FieldMapping field) {
-        if (isNonDefaultMappingAllowed() 
-         && field.getAssociationType() == FieldMetaData.ONE_TO_ONE 
-         && hasJoinTable(field) 
-         && isBidirectional(field)) {
+    public boolean isBi1To1JT(FieldMapping field) {
+        if (isNonDefaultMappingAllowed() && 
+            field.getAssociationType() == FieldMetaData.ONE_TO_ONE && 
+            hasJoinTable(field) && 
+            isBidirectional(field)) {
             field.getValueMapping().getValueInfo().setColumns(field.getElementMapping().getValueInfo().getColumns());
             return true;
         }
         return false;
     }
     
-    public boolean isUnidirectionalOneToManyForeignKey(FieldMapping field) {
-        if (isNonDefaultMappingAllowed() 
-         && field.getAssociationType() == FieldMetaData.ONE_TO_MANY 
-         && hasJoinColumn(field) 
-         && !isBidirectional(field)) {
+    public boolean isUni1ToMFK(FieldMapping field) {
+        if (isNonDefaultMappingAllowed() && 
+            field.getAssociationType() == FieldMetaData.ONE_TO_MANY &&
+            hasJoinColumn(field) &&
+            !isBidirectional(field)) {
             field.getElementMapping().getValueInfo().setColumns(field.getValueInfo().getColumns());
             return true;
         }
         return false;
     }
     
-    public boolean isBidirectionalManyToOneJoinTable(FieldMapping field) {
+    public boolean isBiMTo1JT(FieldMapping field) {
         FieldMapping mapped = field.getMappedByMapping();
         if (isNonDefaultMappingAllowed()) {
             if (field.getAssociationType() == FieldMetaData.ONE_TO_MANY ) {
                 if (mapped != null && hasJoinTable(mapped))
                     return true;
             } else if (field.getAssociationType() == FieldMetaData.MANY_TO_ONE) {
-                if (getBidirectionalOneToManyJoinTableField(field) != null)
+                if (getBi_1ToM_JoinTableField(field) != null)
                     return true;
             }
         }
         return false;
     }
 
-    /**
-     * Gets the inverse field of bidirectional many to one relation using join table strategy
-     * for the given field.
-     */
-    public FieldMapping getBidirectionalOneToManyJoinTableField(FieldMapping field) {
+    // return the inverse field of bidirectional many to one
+    // relation using join table strategy
+    public FieldMapping getBi_1ToM_JoinTableField(FieldMapping field) {
         if (isNonDefaultMappingAllowed()) {
             if (field.getAssociationType() == FieldMetaData.ONE_TO_MANY) {
                 FieldMapping mappedBy = field.getMappedByMapping();
@@ -1155,10 +1159,9 @@ public class MappingRepository extends M
         return null;
     }
 
-    /**
-     * Gets the owning field of bidirectional one to many relation using join table strategy of the given field.
-     */
-    public FieldMapping getBidirectionalManyToOneJoinTableField(FieldMapping field) {
+    // return the owning field of bidirectional one to many
+    // relation using join table strategy
+    public FieldMapping getBi_MTo1_JoinTableField(FieldMapping field) {
         if (isNonDefaultMappingAllowed()) {
             if (field.getAssociationType() == FieldMetaData.MANY_TO_ONE) {
                 if (!hasJoinTable(field))

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -37,10 +37,8 @@ import org.apache.openjpa.jdbc.sql.Row;
 import org.apache.openjpa.jdbc.sql.RowManager;
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
 import org.apache.openjpa.jdbc.sql.Select;
-import org.apache.openjpa.jdbc.sql.SelectExecutor;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.lib.util.Localizer;
-import org.apache.openjpa.lib.util.ThreadGate;
 import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.meta.ValueStrategies;
 import org.apache.openjpa.util.InternalException;
@@ -51,26 +49,23 @@ import org.apache.openjpa.util.UserExcep
  * Mapping for a single-valued field that delegates to a {@link ValueHandler}.
  *
  * @author Abe White
- * @author Pinaki Poddar (select cache)
  * @since 0.4.0
  */
-@SuppressWarnings("serial")
 public class HandlerFieldStrategy
     extends AbstractFieldStrategy
     implements Joinable, Embeddable {
 
     private static final Object NULL = new Object();
 
-    private static final Localizer _loc = Localizer.forPackage(HandlerFieldStrategy.class);
+    private static final Localizer _loc = Localizer.forPackage
+        (HandlerFieldStrategy.class);
 
     protected Column[] _cols = null;
     protected ColumnIO _io = null;
     protected Object[] _args = null;
     protected boolean _load = false;
     protected boolean _lob = false;
-    private Select    _executor;
-    private ThreadGate _lock = new ThreadGate();
-    
+
     public void map(boolean adapt) {
         if (field.getHandler() == null)
             throw new MetaDataException(_loc.get("no-handler", field));
@@ -225,34 +220,21 @@ public class HandlerFieldStrategy
                 return;
             }
         }
-        Select sel;
+
+        Select sel = store.getSQLFactory().newSelect();
+        sel.select(_cols);
+        field.wherePrimaryKey(sel, sm, store);
+
+        Result res = sel.execute(store, fetch);
+        Object val = null;
         try {
-        	_lock.lock();
-	        if (_executor == null) {
-	        	sel = store.getSQLFactory().newSelect();
-	        	if (store.getConfiguration().getSelectCacheEnabled()) {
-	        		_executor = sel;
-	        	}
-	            sel.select(_cols);
-	        } else {
-	        	sel = _executor;
-	        }
-	        
-	        field.wherePrimaryKey(sel, sm, store);
-	
-	        Result res = sel.execute(store, fetch);
-	        Object val = null;
-	        try {
-	            if (res.next())
-	                val = HandlerStrategies.loadDataStore(field, res, null, _cols);
-	        } finally {
-	            res.close();
-	        }
-	
-	        loadEmbedded(sm, store, fetch, val);
+            if (res.next())
+                val = HandlerStrategies.loadDataStore(field, res, null, _cols);
         } finally {
-        	_lock.unlock();
+            res.close();
         }
+
+        loadEmbedded(sm, store, fetch, val);
     }
 
     public Object toDataStoreValue(Object val, JDBCStore store) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerRelationMapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerRelationMapTableFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerRelationMapTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/HandlerRelationMapTableFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -87,7 +87,7 @@ public class HandlerRelationMapTableFiel
         union.select(new Union.Selector() {
             public void select(Select sel, int idx) {
                 sel.select(_kcols);
-                if (field.isUnidirectionalOneToManyForeignKey()) {
+                if (field.isUni1ToMFK()) {
                     sel.whereForeignKey(field.getElementMapping().getForeignKey(),
                         sm.getObjectId(), field.getElementMapping().getDeclaredTypeMapping(), store);
                     sel.select(vals[idx], field.getElementMapping().
@@ -146,11 +146,10 @@ public class HandlerRelationMapTableFiel
             throw new MetaDataException(_loc.get("not-relation", val));
         
         FieldMapping mapped = field.getMappedByMapping();
-        if (field.isUnidirectionalOneToManyForeignKey() 
-        || (!field.isBidirectionalManyToOneJoinTable() && mapped != null)) { 
+        if (field.isUni1ToMFK() || (!field.isBiMTo1JT() && mapped != null)) { 
             // map to the owner table
             handleMappedByForeignKey(adapt);
-        } else if (field.isBidirectionalManyToOneJoinTable() || mapped == null) { 
+        } else if (field.isBiMTo1JT() || mapped == null) { 
             // map to a separate table
             field.mapJoin(adapt, true);
             if (val.getTypeMapping().isMapped()) {
@@ -187,11 +186,11 @@ public class HandlerRelationMapTableFiel
         if (map == null || map.isEmpty())
             return;
         
-        if (!field.isBidirectionalManyToOneJoinTable() && field.getMappedBy() != null)
+        if (!field.isBiMTo1JT() && field.getMappedBy() != null)
             return;
 
         Row row = null;
-        if (!field.isUnidirectionalOneToManyForeignKey()) {
+        if (!field.isUni1ToMFK()) {
             row = rm.getSecondaryRow(field.getTable(), Row.ACTION_INSERT);
             row.setForeignKey(field.getJoinForeignKey(), field.getJoinColumnIO(),
                 sm);
@@ -205,7 +204,7 @@ public class HandlerRelationMapTableFiel
             entry = (Map.Entry) itr.next();
             valsm = RelationStrategies.getStateManager(entry.getValue(),
                 ctx);
-            if (field.isUnidirectionalOneToManyForeignKey()){
+            if (field.isUni1ToMFK()){
                 row = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                     Row.ACTION_UPDATE, valsm, true);
                 row.wherePrimaryKey(valsm);
@@ -224,7 +223,7 @@ public class HandlerRelationMapTableFiel
             // from the view point of the owned side
             PersistenceCapable obj = sm.getPersistenceCapable();
             if (!populateKey(row, valsm, obj, ctx, rm, store)) {
-                if (!field.isUnidirectionalOneToManyForeignKey())
+                if (!field.isUni1ToMFK())
                     rm.flushSecondaryRow(row);
             }
         }
@@ -239,7 +238,7 @@ public class HandlerRelationMapTableFiel
 
     public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if (field.getMappedBy() != null && !field.isBidirectionalManyToOneJoinTable())
+        if (field.getMappedBy() != null && !field.isBiMTo1JT())
             return;
 
         Map map = (Map) sm.fetchObject(field.getIndex());
@@ -270,7 +269,7 @@ public class HandlerRelationMapTableFiel
         Object mkey;
         if (canChange && !change.isEmpty()) {
             Row changeRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 changeRow = rm.getSecondaryRow(field.getTable(),
                     Row.ACTION_UPDATE);
                 changeRow.whereForeignKey(field.getJoinForeignKey(), sm);
@@ -279,7 +278,7 @@ public class HandlerRelationMapTableFiel
             for (Iterator itr = change.iterator(); itr.hasNext();) {
                 mkey = itr.next();
                 valsm = RelationStrategies.getStateManager(map.get(mkey), ctx);
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     changeRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                         Row.ACTION_UPDATE, valsm, true);
                     changeRow.wherePrimaryKey(valsm);
@@ -289,7 +288,7 @@ public class HandlerRelationMapTableFiel
                 }
                 
                 HandlerStrategies.where(key, mkey, store, changeRow, _kcols);
-                if (!field.isUnidirectionalOneToManyForeignKey())
+                if (!field.isUni1ToMFK())
                     rm.flushSecondaryRow(changeRow);
             }
         }
@@ -298,14 +297,14 @@ public class HandlerRelationMapTableFiel
         Collection rem = ct.getRemoved();
         if (!rem.isEmpty() || (!canChange && !change.isEmpty())) {
             Row delRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 delRow = rm.getSecondaryRow(field.getTable(),
                     Row.ACTION_DELETE);
                 delRow.whereForeignKey(field.getJoinForeignKey(), sm);
             }
             for (Iterator itr = rem.iterator(); itr.hasNext();) {
                 mkey = itr.next();
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     updateSetNull(sm, mkey, store, rm);
                 } else {
                     HandlerStrategies.where(key, mkey, store, delRow, _kcols);
@@ -315,7 +314,7 @@ public class HandlerRelationMapTableFiel
             if (!canChange && !change.isEmpty()) {
                 for (Iterator itr = change.iterator(); itr.hasNext();) {
                     mkey = itr.next();
-                    if (field.isUnidirectionalOneToManyForeignKey()){
+                    if (field.isUni1ToMFK()){
                         updateSetNull(sm, mkey, store, rm);
                     } else { 
                         HandlerStrategies.where(key, itr.next(), store, delRow,  _kcols);
@@ -329,7 +328,7 @@ public class HandlerRelationMapTableFiel
         Collection add = ct.getAdded();
         if (!add.isEmpty() || (!canChange && !change.isEmpty())) {
             Row addRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 addRow = rm.getSecondaryRow(field.getTable(),
                         Row.ACTION_INSERT);
                 addRow.setForeignKey(field.getJoinForeignKey(),
@@ -338,7 +337,7 @@ public class HandlerRelationMapTableFiel
             for (Iterator itr = add.iterator(); itr.hasNext();) {
                 mkey = itr.next();
                 valsm = RelationStrategies.getStateManager(map.get(mkey), ctx);
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     addRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                         Row.ACTION_UPDATE, valsm, true);
                     addRow.wherePrimaryKey(valsm);
@@ -349,14 +348,14 @@ public class HandlerRelationMapTableFiel
                 
                 HandlerStrategies.set(key, mkey, store, addRow, _kcols,
                     _kio, true);
-                if (!field.isUnidirectionalOneToManyForeignKey())
+                if (!field.isUni1ToMFK())
                     rm.flushSecondaryRow(addRow);
             }
             if (!canChange && !change.isEmpty()) {
                 for (Iterator itr = change.iterator(); itr.hasNext();) {
                     mkey = itr.next();
                     valsm = RelationStrategies.getStateManager(map.get(mkey), ctx);
-                    if (field.isUnidirectionalOneToManyForeignKey()){
+                    if (field.isUni1ToMFK()){
                         addRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                             Row.ACTION_UPDATE, valsm, true);
                         addRow.wherePrimaryKey(valsm);
@@ -367,7 +366,7 @@ public class HandlerRelationMapTableFiel
                     
                     HandlerStrategies.set(key, mkey, store, addRow, _kcols,
                         _kio, true);
-                    if (!field.isUnidirectionalOneToManyForeignKey())
+                    if (!field.isUni1ToMFK())
                         rm.flushSecondaryRow(addRow);
                 }
             }
@@ -414,9 +413,9 @@ public class HandlerRelationMapTableFiel
     
     public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if ((field.getMappedBy() != null && !field.isBidirectionalManyToOneJoinTable()))
+        if ((field.getMappedBy() != null && !field.isBiMTo1JT()))
             return;
-        if (field.isUnidirectionalOneToManyForeignKey()) {
+        if (field.isUni1ToMFK()) {
             Map mapObj = (Map)sm.fetchObject(field.getIndex());
             updateSetNull(sm, store, rm, mapObj.keySet());
             return;

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MapTableFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -112,10 +112,10 @@ public abstract class MapTableFieldStrat
             throw new MetaDataException(_loc.get("mapped-by-key", field));
 
         // Non-default mapping Uni-/OneToMany/ForeignKey allows schema components
-        if (field.isUnidirectionalOneToManyForeignKey())  
+        if (field.isUni1ToMFK())  
             return;
-        if (field.isBidirectionalManyToOneJoinTable())
-            field.setBidirectionalOneToManyJoinTableInfo();
+        if (field.isBiMTo1JT())
+            field.setBi1MJoinTableInfo();
         field.getValueInfo().assertNoSchemaComponents(field, !adapt);
     }
     

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -28,7 +28,6 @@ import java.util.Set;
 
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.enhance.ReflectingPersistenceCapable;
-import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
@@ -38,6 +37,7 @@ import org.apache.openjpa.jdbc.meta.Fiel
 import org.apache.openjpa.jdbc.meta.FieldStrategy;
 import org.apache.openjpa.jdbc.meta.Joinable;
 import org.apache.openjpa.jdbc.meta.MappingInfo;
+import org.apache.openjpa.jdbc.meta.ValueHandler;
 import org.apache.openjpa.jdbc.meta.ValueMapping;
 import org.apache.openjpa.jdbc.meta.ValueMappingImpl;
 import org.apache.openjpa.jdbc.meta.ValueMappingInfo;
@@ -55,14 +55,13 @@ import org.apache.openjpa.jdbc.sql.SQLBu
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.jdbc.sql.SelectExecutor;
 import org.apache.openjpa.jdbc.sql.Union;
+import org.apache.openjpa.kernel.LockManager;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
-import org.apache.openjpa.lib.util.ThreadGate;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
-import org.apache.openjpa.meta.MetaDataModes;
 import org.apache.openjpa.util.ApplicationIds;
 import org.apache.openjpa.util.ImplHelper;
 import org.apache.openjpa.util.InternalException;
@@ -75,34 +74,27 @@ import org.apache.openjpa.util.Unsupport
 /**
  * Mapping for a single-valued relation to another entity.
  *
- * <br>
- * The strategy may reuse the same {@link SelectExecutor select} if the 
- * {@link JDBCConfiguration#getSelectCacheEnabled() configuration option}
- * instructs to do so. 
-
  * @author Abe White
- * @author Pinaki Poddar (select caching)
  * @since 0.4.0
  */
-@SuppressWarnings("serial")
 public class RelationFieldStrategy
     extends AbstractFieldStrategy
     implements Joinable, Embeddable {
 
-    private static final Localizer _loc = Localizer.forPackage(RelationFieldStrategy.class);
+    private static final Localizer _loc = Localizer.forPackage
+        (RelationFieldStrategy.class);
 
     private Boolean _fkOid = null;
     
-    private SelectExecutor _executor;
-    private ThreadGate _lock = new ThreadGate();
-    
     public void map(boolean adapt) {
         if (field.getTypeCode() != JavaTypes.PC || field.isEmbeddedPC())
             throw new MetaDataException(_loc.get("not-relation", field));
 
-        field.getKeyMapping().getValueInfo().assertNoSchemaComponents(field.getKey(), !adapt);
+        field.getKeyMapping().getValueInfo().assertNoSchemaComponents
+            (field.getKey(), !adapt);
         if (!field.isNonDefaultMappingUsingJoinTableStrategy())
-            field.getElementMapping().getValueInfo().assertNoSchemaComponents(field.getElement(), !adapt);
+            field.getElementMapping().getValueInfo().assertNoSchemaComponents
+                (field.getElement(), !adapt);
         boolean criteria = field.getValueInfo().getUseClassCriteria();
 
         // check for named inverse
@@ -110,33 +102,40 @@ public class RelationFieldStrategy
         if (mapped != null) {
             field.getMappingInfo().assertNoSchemaComponents(field, !adapt);
             field.getValueInfo().assertNoSchemaComponents(field, !adapt);
-            mapped.resolve(MetaDataModes.MODE_META | MetaDataModes.MODE_MAPPING);
+            mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
 
             if (!mapped.isMapped() || mapped.isSerialized())
-                throw new MetaDataException(_loc.get("mapped-by-unmapped", field, mapped));
+                throw new MetaDataException(_loc.get("mapped-by-unmapped",
+                    field, mapped));
 
             if (mapped.getTypeCode() == JavaTypes.PC) {
-                if (mapped.getJoinDirection() == FieldMapping.JOIN_FORWARD) {
-                    field.setJoinDirection(FieldMapping.JOIN_INVERSE);
-                    field.setColumns(mapped.getDefiningMapping().getPrimaryKeyColumns());
+                if (mapped.getJoinDirection() == mapped.JOIN_FORWARD) {
+                    field.setJoinDirection(field.JOIN_INVERSE);
+                    field.setColumns(mapped.getDefiningMapping().
+                        getPrimaryKeyColumns());
                 } else if (isTypeUnjoinedSubclass(mapped))
                     throw new MetaDataException(_loc.get
-                        ("mapped-inverse-unjoined", field.getName(), field.getDefiningMapping(), mapped));
+                        ("mapped-inverse-unjoined", field.getName(),
+                            field.getDefiningMapping(), mapped));
 
-                field.setForeignKey(mapped.getForeignKey(field.getDefiningMapping()));
+                field.setForeignKey(mapped.getForeignKey
+                    (field.getDefiningMapping()));
             } else if (mapped.getElement().getTypeCode() == JavaTypes.PC) {
                 if (isTypeUnjoinedSubclass(mapped.getElementMapping()))
                     throw new MetaDataException(_loc.get
-                        ("mapped-inverse-unjoined", field.getName(), field.getDefiningMapping(), mapped));
+                        ("mapped-inverse-unjoined", field.getName(),
+                            field.getDefiningMapping(), mapped));
 
                 // warn the user about making the collection side the owner
                 Log log = field.getRepository().getLog();
                 if (log.isInfoEnabled())
                     log.info(_loc.get("coll-owner", field, mapped));
-                field.setForeignKey(mapped.getElementMapping().getForeignKey());
-            } else {
-                throw new MetaDataException(_loc.get("not-inv-relation", field, mapped));
-            }
+                field.setForeignKey(mapped.getElementMapping().
+                    getForeignKey());
+            } else
+                throw new MetaDataException(_loc.get("not-inv-relation",
+                    field, mapped));
+
             field.setUseClassCriteria(criteria);
             return;
         } 
@@ -158,22 +157,24 @@ public class RelationFieldStrategy
             field.getMappingInfo().setColumns(null);
         }
         
-        if (!field.isBidirectionalManyToOneJoinTable())
+        if (!field.isBiMTo1JT())
             field.mapJoin(adapt, false);
         if (field.getTypeMapping().isMapped()) {
             if (field.getMappedByIdValue() != null) 
                 setMappedByIdColumns();            
              
-            if (!field.isBidirectionalManyToOneJoinTable()) {
-                ForeignKey fk = vinfo.getTypeJoin(field, field.getName(), true, adapt);
+            if (!field.isBiMTo1JT()) {
+                ForeignKey fk = vinfo.getTypeJoin(field, field.getName(), true,
+                    adapt);
                 field.setForeignKey(fk);
             }
             field.setColumnIO(vinfo.getColumnIO());
-            if (vinfo.getJoinDirection() == MappingInfo.JOIN_INVERSE)
-                field.setJoinDirection(FieldMapping.JOIN_INVERSE);
-        } else {
-            RelationStrategies.mapRelationToUnmappedPC(field, field.getName(), adapt);
-        }
+            if (vinfo.getJoinDirection() == vinfo.JOIN_INVERSE)
+                field.setJoinDirection(field.JOIN_INVERSE);
+        } else
+            RelationStrategies.mapRelationToUnmappedPC(field, field.getName(),
+                adapt);
+
         field.setUseClassCriteria(criteria);
         field.mapPrimaryKey(adapt);
         PrimaryKey pk = field.getTable().getPrimaryKey();
@@ -208,10 +209,11 @@ public class RelationFieldStrategy
         }
     }
 
-    private List<Column> getMappedByIdColumns(FieldMapping pk) {
-        ClassMetaData embeddedId = ((ValueMappingImpl)pk.getValue()).getEmbeddedMetaData();
+    private List getMappedByIdColumns(FieldMapping pk) {
+        ClassMetaData embeddedId = ((ValueMappingImpl)pk.getValue()).
+            getEmbeddedMetaData();
         Column[] pkCols = null;
-        List<Column> cols = new ArrayList<Column>();
+        List cols = new ArrayList();
         String mappedByIdValue = field.getMappedByIdValue();
         if (embeddedId != null) {
             FieldMetaData[] fmds = embeddedId.getFields();
@@ -219,19 +221,20 @@ public class RelationFieldStrategy
                 if ((fmds[i].getName().equals(mappedByIdValue)) ||
                     mappedByIdValue.length() == 0) {
                     if (fmds[i].getValue().getEmbeddedMetaData() != null) {
-                        EmbedValueHandler.getEmbeddedIdCols((FieldMapping)fmds[i], cols);
-                    } else {
-                        EmbedValueHandler.getIdColumns((FieldMapping)fmds[i], cols);
-                    }
+                        EmbedValueHandler.getEmbeddedIdCols(
+                                (FieldMapping)fmds[i], cols);
+                    } else 
+                        EmbedValueHandler.getIdColumns(
+                                (FieldMapping)fmds[i], cols);
                 }
             }
             return cols;
         } else { // primary key is single-value
-            Class<?> pkType = pk.getDeclaredType();
+            Class pkType = pk.getDeclaredType();
             FieldMetaData[] pks = field.getValue().getDeclaredTypeMetaData().
                     getPrimaryKeyFields();
             if (pks.length != 1 || pks[0].getDeclaredType() != pkType)
-                return Collections.emptyList();
+                return Collections.EMPTY_LIST;
             pkCols = pk.getColumns();
             for (int i = 0; i < pkCols.length; i++)
                 cols.add(pkCols[i]);
@@ -268,11 +271,11 @@ public class RelationFieldStrategy
 
         OpenJPAStateManager rel = RelationStrategies.getStateManager
             (sm.fetchObjectField(field.getIndex()), store.getContext());
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE)
+        if (field.getJoinDirection() == field.JOIN_INVERSE)
             updateInverse(sm, rel, store, rm);
         else {
             Row row = field.getRow(sm, store, rm, Row.ACTION_INSERT);
-            if (row != null && !field.isBidirectionalManyToOneJoinTable()) {
+            if (row != null && !field.isBiMTo1JT()) {
                 field.setForeignKey(row, rel);
                 // this is for bi-directional maps, the key and value of the 
                 // map are stored in the table of the mapped-by entity  
@@ -292,7 +295,7 @@ public class RelationFieldStrategy
         if (mapField == null)
             return;
         
-        Map<Object,Object> mapObj = (Map<Object,Object>)rel.fetchObjectField(mapField.getIndex());
+        Map mapObj = (Map)rel.fetchObjectField(mapField.getIndex());
         Object keyObj = getMapKeyObj(mapObj, sm.getPersistenceCapable());
         ValueMapping key = mapField.getKeyMapping();
         if (!key.isEmbedded()) {
@@ -308,11 +311,14 @@ public class RelationFieldStrategy
         } else {
             // key is an embeddable or basic type
             FieldStrategy strategy = mapField.getStrategy(); 
-            if (strategy instanceof HandlerRelationMapTableFieldStrategy) {
-                HandlerRelationMapTableFieldStrategy strat = (HandlerRelationMapTableFieldStrategy) strategy;
+            if (strategy instanceof  
+                    HandlerRelationMapTableFieldStrategy) {
+                HandlerRelationMapTableFieldStrategy strat = 
+                    (HandlerRelationMapTableFieldStrategy) strategy;
                 Column[] kcols = strat.getKeyColumns((ClassMapping)meta);
                 ColumnIO kio = strat.getKeyColumnIO();
-                HandlerStrategies.set(key, keyObj, store, row, kcols, kio, true);
+                HandlerStrategies.set(key, keyObj, store, row, kcols,
+                        kio, true);
             }
         } 
     }
@@ -321,18 +327,19 @@ public class RelationFieldStrategy
         FieldMapping[] fields = ((ClassMapping)meta).getFieldMappings();
         for (int i = 0; i < fields.length; i++) {
             FieldMetaData mappedBy = fields[i].getMappedByMetaData();
-            if (fields[i].getDeclaredTypeCode() == JavaTypes.MAP && mappedBy == field)  
+            if (fields[i].getDeclaredTypeCode() == JavaTypes.MAP &&
+                mappedBy == field)  
                 return fields[i];
         } 
         return null;    
     }
     
-    private Object getMapKeyObj(Map<Object,Object> mapObj, Object value) {
+    private Object getMapKeyObj(Map mapObj, Object value) {
         if (value instanceof ReflectingPersistenceCapable)
             value = ((ReflectingPersistenceCapable)value).getManagedInstance(); 
 
-        Set<Map.Entry<Object,Object>> entries = mapObj.entrySet();
-        for (Map.Entry<Object,Object> entry : entries) {
+        Set<Map.Entry> entries = mapObj.entrySet();
+        for (Map.Entry entry : entries) {
             if (entry.getValue() == value)
                 return entry.getKey();
         }
@@ -348,7 +355,7 @@ public class RelationFieldStrategy
         OpenJPAStateManager rel = RelationStrategies.getStateManager
             (sm.fetchObjectField(field.getIndex()), store.getContext());
 
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE) {
+        if (field.getJoinDirection() == field.JOIN_INVERSE) {
             nullInverse(sm, rm);
             updateInverse(sm, rel, store, rm);
         } else {
@@ -356,22 +363,22 @@ public class RelationFieldStrategy
                     field.isBidirectionalJoinTableMappingNonOwner()) ?
                     Row.ACTION_DELETE : Row.ACTION_UPDATE;
             Row row = field.getRow(sm, store, rm, action);
-            if (row != null && !field.isBidirectionalManyToOneJoinTable()) {
+            if (row != null && !field.isBiMTo1JT()) {
                 field.setForeignKey(row, rel);
                 // this is for bi-directional maps, the key and value of the 
                 // map are stored in the table of the mapped-by entity  
                 setMapKey(sm, rel, store, row);
             }
             
-            if (field.isBidirectionalManyToOneJoinTable()) { // also need to update the join table
+            if (field.isBiMTo1JT()) { // also need to update the join table
                 PersistenceCapable invPC = (PersistenceCapable)sm.fetchObject(
-                    field.getBidirectionalOneToManyJoinTableField().getIndex());
+                    field.getBi_1ToM_JTField().getIndex());
                 Row secondaryRow = null;
                 if (invPC != null) {
-                    secondaryRow = rm.getSecondaryRow(field.getBidirectionalOneToManyJoinForeignKey().getTable(),
+                    secondaryRow = rm.getSecondaryRow(field.getBi1ToMJoinFK().getTable(),
                         Row.ACTION_INSERT);
-                    secondaryRow.setForeignKey(field.getBidirectionalOneToManyElementForeignKey(), null, sm);
-                    secondaryRow.setForeignKey(field.getBidirectionalOneToManyJoinForeignKey(), null, 
+                    secondaryRow.setForeignKey(field.getBi1ToMElemFK(), null, sm);
+                    secondaryRow.setForeignKey(field.getBi1ToMJoinFK(), null, 
                         RelationStrategies.getStateManager(invPC,
                         store.getContext()));
                     rm.flushSecondaryRow(secondaryRow);
@@ -385,7 +392,7 @@ public class RelationFieldStrategy
         if (field.getMappedBy() != null)
             return;
 
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE) {
+        if (field.getJoinDirection() == field.JOIN_INVERSE) {
             if (sm.getLoaded().get(field.getIndex())) {
                 OpenJPAStateManager rel = RelationStrategies.getStateManager(sm.
                     fetchObjectField(field.getIndex()), store.getContext());
@@ -497,7 +504,7 @@ public class RelationFieldStrategy
     public int supportsSelect(Select sel, int type, OpenJPAStateManager sm,
         JDBCStore store, JDBCFetchConfiguration fetch) {
         if (type == Select.TYPE_JOINLESS)
-            return (field.getJoinDirection() != FieldMapping.JOIN_INVERSE
+            return (field.getJoinDirection() != field.JOIN_INVERSE
                 && sel.isSelected(field.getTable())) ? 1 : 0;
         if (type == Select.TYPE_TWO_PART)
             return 1;
@@ -528,15 +535,17 @@ public class RelationFieldStrategy
         final OpenJPAStateManager sm, final JDBCStore store,
         final JDBCFetchConfiguration fetch, final int eagerMode) {
         final ClassMapping[] clss = field.getIndependentTypeMappings();
-        if (!(sel instanceof Union)) {
+        if (!(sel instanceof Union))
             selectEagerParallel((Select) sel, clss[0], store, fetch, eagerMode);
-        } else {
+        else {
             Union union = (Union) sel;
-            if (fetch.getSubclassFetchMode (field.getTypeMapping()) != JDBCFetchConfiguration.EAGER_JOIN)
+            if (fetch.getSubclassFetchMode (field.getTypeMapping()) 
+                != JDBCFetchConfiguration.EAGER_JOIN)
                 union.abortUnion();
             union.select(new Union.Selector() {
                 public void select(Select sel, int idx) {
-                    selectEagerParallel(sel, clss[idx], store, fetch, eagerMode);
+                    selectEagerParallel(sel, clss[idx], store, fetch,
+                        eagerMode);
                 }
             });
         }
@@ -547,7 +556,7 @@ public class RelationFieldStrategy
      */
     private void selectEagerParallel(Select sel, ClassMapping cls,
         JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode) {
-        if (field.isBidirectionalManyToOneJoinTable())
+        if (field.isBiMTo1JT())
             return;
         sel.selectPrimaryKey(field.getDefiningMapping());
         // set a variable name that does not conflict with any in the query;
@@ -562,7 +571,7 @@ public class RelationFieldStrategy
 
     public void selectEagerJoin(Select sel, OpenJPAStateManager sm,
         JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode) {
-        if (field.isBidirectionalManyToOneJoinTable()) 
+        if (field.isBiMTo1JT()) 
             return;
 
         // limit the eager mode to single on recursive eager fetching b/c
@@ -581,7 +590,7 @@ public class RelationFieldStrategy
      * Add the joins needed to select/load eager data.
      */
     private Joins eagerJoin(Joins joins, ClassMapping cls, boolean forceInner) {
-        boolean inverse = field.getJoinDirection() == FieldMapping.JOIN_INVERSE;
+        boolean inverse = field.getJoinDirection() == field.JOIN_INVERSE;
         if (!inverse) {
             joins = join(joins, false);
             joins = setEmbeddedVariable(joins);
@@ -609,7 +618,7 @@ public class RelationFieldStrategy
 
     public int select(Select sel, OpenJPAStateManager sm, JDBCStore store,
         JDBCFetchConfiguration fetch, int eagerMode) {
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE)
+        if (field.getJoinDirection() == field.JOIN_INVERSE)
             return -1;
         // already cached oid?
         if (sm != null && sm.getIntermediate(field.getIndex()) != null)
@@ -624,11 +633,11 @@ public class RelationFieldStrategy
         JDBCFetchConfiguration fetch, Object res)
         throws SQLException {
         // process batched results if we haven't already
-        Map<Object,Object> rels;
+        Map rels;
         if (res instanceof Result)
             rels = processEagerParallelResult(sm, store, fetch, (Result) res);
         else
-            rels = (Map<Object,Object>) res;
+            rels = (Map) res;
 
         // store object for this oid in instance
         sm.storeObject(field.getIndex(), rels.remove(sm.getObjectId()));
@@ -638,7 +647,7 @@ public class RelationFieldStrategy
     /**
      * Process the given batched result.
      */
-    private Map<Object,Object> processEagerParallelResult(OpenJPAStateManager sm,
+    private Map processEagerParallelResult(OpenJPAStateManager sm,
         JDBCStore store, JDBCFetchConfiguration fetch, Result res)
         throws SQLException {
         // do same joins as for load
@@ -648,7 +657,7 @@ public class RelationFieldStrategy
         Joins joins = res.newJoins().setVariable("*");
         eagerJoin(joins, clss[0], true);
 
-        Map<Object,Object> rels = new HashMap<Object,Object>();
+        Map rels = new HashMap();
         ClassMapping owner = field.getDefiningMapping();
         ClassMapping cls;
         Object oid;
@@ -667,7 +676,7 @@ public class RelationFieldStrategy
     public void loadEagerJoin(OpenJPAStateManager sm, JDBCStore store,
         JDBCFetchConfiguration fetch, Result res)
         throws SQLException {
-        if (field.isBidirectionalManyToOneJoinTable())
+        if (field.isBiMTo1JT())
             return;
         ClassMapping cls = field.getIndependentTypeMappings()[0];
 
@@ -710,7 +719,7 @@ public class RelationFieldStrategy
     public void load(OpenJPAStateManager sm, JDBCStore store,
         JDBCFetchConfiguration fetch, Result res)
         throws SQLException {
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE)
+        if (field.getJoinDirection() == field.JOIN_INVERSE)
             return;
         // cached oid?
         if (sm != null && sm.getIntermediate(field.getIndex()) != null)
@@ -723,7 +732,7 @@ public class RelationFieldStrategy
         // get the related object's oid
         ClassMapping relMapping = field.getTypeMapping();
         Object oid = null;
-        if (relMapping.isMapped() && !field.isBidirectionalManyToOneJoinTable()) { 
+        if (relMapping.isMapped() && !field.isBiMTo1JT()) { 
             oid = relMapping.getObjectId(store, res, field.getForeignKey(),
                     field.getPolymorphic() != ValueMapping.POLY_FALSE, null);
         } else {
@@ -737,7 +746,8 @@ public class RelationFieldStrategy
                 if (cols.length == 1) {
                     Object val = res.getObject(cols[0], null, null);
                     if (val != null)
-                        oid = ApplicationIds.fromPKValues(new Object[]{ val }, relMapping);
+                        oid = ApplicationIds.fromPKValues(new Object[]{ val },
+                            relMapping);
                 } else {
                     Object[] vals = new Object[cols.length];
                     for (int i = 0; i < cols.length; i++) {
@@ -757,7 +767,8 @@ public class RelationFieldStrategy
             sm.setIntermediate(field.getIndex(), oid);
     }
 
-    public void load(final OpenJPAStateManager sm, final JDBCStore store, final JDBCFetchConfiguration fetch)
+    public void load(final OpenJPAStateManager sm, final JDBCStore store,
+        final JDBCFetchConfiguration fetch)
         throws SQLException {
         // check for cached oid value, or load oid if no way to join
         if (Boolean.TRUE.equals(_fkOid)) {
@@ -776,64 +787,44 @@ public class RelationFieldStrategy
         // select related mapping columns; joining from the related type
         // back to our fk table if not an inverse mapping (in which case we
         // can just make sure the inverse cols == our pk values)
-        Union union;
+        Union union = store.getSQLFactory().newUnion(rels.length);
+        union.setExpectedResultCount(1, false);
+        if (fetch.getSubclassFetchMode(field.getTypeMapping())
+            != JDBCFetchConfiguration.EAGER_JOIN)
+            union.abortUnion();
+        union.select(new Union.Selector() {
+            public void select(Select sel, int idx) {
+                if (field.getJoinDirection() == field.JOIN_INVERSE)
+                    sel.whereForeignKey(field.getForeignKey(rels[idx]),
+                        sm.getObjectId(), field.getDefiningMapping(), store);
+                else {
+                    if (!field.isBiMTo1JT()) {
+                        resJoins[idx] = sel.newJoins().joinRelation(field.getName(),
+                            field.getForeignKey(rels[idx]), rels[idx],
+                            field.getSelectSubclasses(), false, false);
+                        field.wherePrimaryKey(sel, sm, store);
+                    } else {
+                        resJoins[idx] = sel.newJoins().joinRelation(null,
+                            field.getBi1ToMJoinFK(), rels[idx],
+                            field.getSelectSubclasses(), false, false);
+                        sel.whereForeignKey(field.getBi1ToMElemFK(), sm.getObjectId(), 
+                            field.getDefiningMapping(), store);
+                    }
+                }
+                sel.select(rels[idx], subs, store, fetch, fetch.EAGER_JOIN, 
+                    resJoins[idx]);
+            }
+        });
+
+        Result res = union.execute(store, fetch);
         try {
-        	_lock.lock();
-	        if (_executor == null) {
-	        	union = store.getSQLFactory().newUnion(rels.length);
-	            union.setExpectedResultCount(1, false);
-	            if (fetch.getSubclassFetchMode(field.getTypeMapping()) != JDBCFetchConfiguration.EAGER_JOIN)
-	                    union.abortUnion();
-	            if (((JDBCConfiguration)field.getMappingRepository().getConfiguration()).getSelectCacheEnabled()) {
-	            	_executor = union;
-	            }
-	        } else {
-	        	union = (Union)_executor;
-	        }
-	        union.select(new Union.Selector() {
-	            public void select(Select sel, int idx) {
-	            	ForeignKey fk = field.getForeignKey(rels[idx]);
-	            	ClassMapping mapping = field.getDefiningMapping();
-	            	Object oid = sm.getObjectId();
-	                if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE) {
-	                    sel.whereForeignKey(fk, oid, mapping, store);
-	                } else {
-	                    if (!field.isBidirectionalManyToOneJoinTable()) {
-	                    	if (sel.isReadOnly()) {
-	                    		resJoins[idx] = sel.getJoins();
-	                    	} else {
-	                    		resJoins[idx] = sel.newJoins().joinRelation(field.getName(), fk, rels[idx],
-	                                subs, false, false);
-	                    	}
-	                        field.wherePrimaryKey(sel, sm, store);
-	                    } else {
-	                    	if (sel.isReadOnly()) {
-	                    		resJoins[idx] = sel.getJoins();
-	                    	} else { 
-	                    		resJoins[idx] = sel.newJoins().joinRelation(null, 
-	                    				field.getBidirectionalOneToManyJoinForeignKey(), rels[idx],
-	                                    subs, false, false);
-	                    	}
-	                        sel.whereForeignKey(field.getBidirectionalOneToManyElementForeignKey(), 
-	                        		oid, mapping, store);
-	                    }
-	                }
-	                if (!sel.isReadOnly()) {
-	                	sel.select(rels[idx], subs, store, fetch, 
-	                			JDBCFetchConfiguration.EAGER_JOIN, resJoins[idx]);
-	                }
-	            }
-	        });
-	
-	        Result res = union.execute(store, fetch);
-	        try {
-	        	sm.storeObject(field.getIndex(), res.next()
-	            	? res.load(rels[res.indexOf()], store, fetch, resJoins[res.indexOf()]) : null);
-	        } finally {
-	            res.close();
-	        }
+            Object val = null;
+            if (res.next())
+                val = res.load(rels[res.indexOf()], store, fetch,
+                    resJoins[res.indexOf()]);
+            sm.storeObject(field.getIndex(), val);
         } finally {
-        	_lock.unlock();
+            res.close();
         }
     }
 
@@ -846,7 +837,7 @@ public class RelationFieldStrategy
         // because it'll be in the primary table) and see if fk cols are null;
         // if inverse, then we have to do a sub-select to see if any inverse
         // objects point back to this field's owner
-        if (field.getJoinDirection() != FieldMapping.JOIN_INVERSE) {
+        if (field.getJoinDirection() != field.JOIN_INVERSE) {
             //### probably need some sort of subselect here on fk constants
             joins = join(joins, false);
             Column[] cols = field.getColumns();
@@ -855,9 +846,8 @@ public class RelationFieldStrategy
             else
                 sql.append(sel.getColumnAlias(cols[0], joins)).
                     append(" IS ").appendValue(null, cols[0]);
-        } else {
+        } else
             testInverseNull(sql, sel, joins, true);
-        }
     }
 
     public void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins) {
@@ -865,7 +855,7 @@ public class RelationFieldStrategy
         // because it'll be in the primary table) and see if fk cols aren't
         // null; if inverse, then we have to do a sub-select to see if any
         // inverse objects point back to this field's owner
-        if (field.getJoinDirection() != FieldMapping.JOIN_INVERSE) {
+        if (field.getJoinDirection() != field.JOIN_INVERSE) {
             //### probably need some sort of subselect here on fk constants
             joins = join(joins, false);
             Column[] cols = field.getColumns();
@@ -896,27 +886,30 @@ public class RelationFieldStrategy
             sql.append("0 < ");
 
         ForeignKey fk = field.getForeignKey();
-        ContainerFieldStrategy.appendJoinCount(sql, sel, joins, dict, field, fk);
+        ContainerFieldStrategy.appendJoinCount(sql, sel, joins, dict, field,
+            fk);
     }
 
     public Joins join(Joins joins, boolean forceOuter) {
         // if we're not in an inverse object table join normally, otherwise
         // already traversed the relation; just join back to owner table
-        if (field.getJoinDirection() != FieldMapping.JOIN_INVERSE)
+        if (field.getJoinDirection() != field.JOIN_INVERSE)
             return field.join(joins, forceOuter, false);
         ClassMapping[] clss = field.getIndependentTypeMappings();
         if (clss.length != 1)
             throw RelationStrategies.uninversable(field);
         if (forceOuter)
             return joins.outerJoinRelation(field.getName(),
-                field.getForeignKey(), clss[0], field.getSelectSubclasses(), true, false);
+                field.getForeignKey(), clss[0], field.getSelectSubclasses(), 
+                true, false);
         return joins.joinRelation(field.getName(), field.getForeignKey(),
             clss[0], field.getSelectSubclasses(), true, false);
     }
 
-    public Joins joinRelation(Joins joins, boolean forceOuter, boolean traverse) {
+    public Joins joinRelation(Joins joins, boolean forceOuter,
+        boolean traverse) {
         // if this is an inverse mapping it's already joined to the relation
-        if (field.getJoinDirection() == FieldMapping.JOIN_INVERSE)
+        if (field.getJoinDirection() == field.JOIN_INVERSE)
             return joins;
         ClassMapping[] clss = field.getIndependentTypeMappings();
         if (clss.length != 1) {
@@ -953,7 +946,8 @@ public class RelationFieldStrategy
             long id = res.getLong(col, joins);
             if (field.getObjectIdFieldTypeCode() == JavaTypes.LONG)
                 return id;
-            return store.newDataStoreId(id, relmapping, field.getPolymorphic() != ValueMapping.POLY_FALSE);
+            return store.newDataStoreId(id, relmapping, field.getPolymorphic() 
+                != ValueMapping.POLY_FALSE);
         }
 
         if (relmapping.isOpenJPAIdentity())
@@ -1006,21 +1000,27 @@ public class RelationFieldStrategy
             fieldVal = store.getContext().getObjectId(fieldVal);
         if (fieldVal instanceof OpenJPAId)
             fieldVal = ((OpenJPAId) fieldVal).getIdObject();
-        if (relmapping.getObjectIdType() != null && relmapping.getObjectIdType().isInstance(fieldVal)) {
+        if (relmapping.getObjectIdType() != null
+            && relmapping.getObjectIdType().isInstance(fieldVal)) {
             Object[] pks = ApplicationIds.toPKValues(fieldVal, relmapping);
-            fieldVal = pks[relmapping.getField(j.getFieldIndex()).getPrimaryKeyIndex()];
+            fieldVal = pks[relmapping.getField(j.getFieldIndex()).
+                getPrimaryKeyIndex()];
         } else if (relmapping.getObjectIdType() == ObjectId.class && 
             relmapping.getPrimaryKeyFieldMappings()[0].getValueMapping().isEmbedded()) {
-            return j.getJoinValue((fieldVal == null) ? savedFieldVal : fieldVal, col, store);
+            if (fieldVal == null)
+                return j.getJoinValue(savedFieldVal, col, store);
+            return j.getJoinValue(fieldVal, col, store);
         }
         return j.getJoinValue(fieldVal, col, store);
     }
 
-    public Object getJoinValue(OpenJPAStateManager sm, Column col, JDBCStore store) {
+    public Object getJoinValue(OpenJPAStateManager sm, Column col,
+        JDBCStore store) {
         return getJoinValue(sm.fetch(field.getIndex()), col, store);
     }
 
-    public void setAutoAssignedValue(OpenJPAStateManager sm, JDBCStore store, Column col, Object autoInc) {
+    public void setAutoAssignedValue(OpenJPAStateManager sm, JDBCStore store,
+        Column col, Object autoInc) {
         throw new UnsupportedException();
     }
 
@@ -1048,7 +1048,8 @@ public class RelationFieldStrategy
         return UNSUPPORTED;
     }
 
-    public void loadEmbedded(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object val)
+    public void loadEmbedded(OpenJPAStateManager sm, JDBCStore store,
+        JDBCFetchConfiguration fetch, Object val)
         throws SQLException {
         ClassMapping relMapping = field.getTypeMapping();
         Object oid;
@@ -1058,7 +1059,8 @@ public class RelationFieldStrategy
             oid = store.newDataStoreId(((Number) val).longValue(), relMapping,
                 field.getPolymorphic() != ValueMapping.POLY_FALSE);
         else {
-            Object[] pks = (getColumns().length == 1) ? new Object[]{ val } : (Object[]) val;
+            Object[] pks = (getColumns().length == 1) ? new Object[]{ val }
+                : (Object[]) val;
             boolean nulls = true;
             for (int i = 0; nulls && i < pks.length; i++)
                 nulls = pks[i] == null;
@@ -1066,15 +1068,17 @@ public class RelationFieldStrategy
                 oid = null;
             else {
                 oid = ApplicationIds.fromPKValues(pks, relMapping);
-                if (field.getPolymorphic() == ValueMapping.POLY_FALSE && oid instanceof OpenJPAId) {
-                    ((OpenJPAId) oid).setManagedInstanceType(relMapping.getDescribedType());
+                if (field.getPolymorphic() == ValueMapping.POLY_FALSE
+                    && oid instanceof OpenJPAId) {
+                    ((OpenJPAId) oid).setManagedInstanceType(relMapping.
+                        getDescribedType());
                 }
             }
         }
 
-        if (oid == null) {
+        if (oid == null)
             sm.storeObject(field.getIndex(), null);
-        } else {
+        else {
             if (JavaTypes.maybePC(field.getValue()) &&
                 field.getElement().getEmbeddedMetaData() == null) {
                 Object obj = store.find(oid, field, fetch);

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationRelationMapTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationRelationMapTableFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationRelationMapTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationRelationMapTableFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -82,7 +82,7 @@ public class RelationRelationMapTableFie
         kunion.select(new Union.Selector() {
             public void select(Select sel, int idx) {
                 ForeignKey joinFK = null;
-                if (field.isUnidirectionalOneToManyForeignKey()) {
+                if (field.isUni1ToMFK()) {
                     ValueMapping val = field.getElementMapping();
                     ValueMappingInfo vinfo = val.getValueInfo();
                     Table table = vinfo.getTable(val);
@@ -117,7 +117,7 @@ public class RelationRelationMapTableFie
         vunion.setLRS(lrs);
         vunion.select(new Union.Selector() {
             public void select(Select sel, int idx) {
-                if (field.isUnidirectionalOneToManyForeignKey()) {
+                if (field.isUni1ToMFK()) {
                     sel.orderBy(field.getKeyMapping().getColumns(), true, true);
                     sel.select(vals[idx], field.getElementMapping().
                         getSelectSubclasses(), store, fetch, eagerMode, null);
@@ -203,11 +203,10 @@ public class RelationRelationMapTableFie
         FieldMapping mapped = field.getMappedByMapping();
         DBDictionary dict = field.getMappingRepository().getDBDictionary();
         DBIdentifier keyName = null;
-        if (field.isUnidirectionalOneToManyForeignKey() 
-        || (!field.isBidirectionalManyToOneJoinTable() && mapped != null)) { 
+        if (field.isUni1ToMFK() || (!field.isBiMTo1JT() && mapped != null)) { 
             handleMappedByForeignKey(adapt);
             keyName = dict.getValidColumnName(DBIdentifier.newColumn("vkey"), field.getTable());
-        } else if (field.isBidirectionalManyToOneJoinTable() || mapped == null) { 
+        } else if (field.isBiMTo1JT() || mapped == null) { 
             field.mapJoin(adapt, true);
             mapTypeJoin(val, DBIdentifier.newColumn("value"), adapt);
             keyName = dict.getValidColumnName(DBIdentifier.newColumn("key"), field.getTable());
@@ -246,11 +245,11 @@ public class RelationRelationMapTableFie
         if (map == null || map.isEmpty())
             return;
         
-        if (!field.isBidirectionalManyToOneJoinTable() && field.getMappedBy() != null)
+        if (!field.isBiMTo1JT() && field.getMappedBy() != null)
             return;
 
         Row row = null;
-        if (!field.isUnidirectionalOneToManyForeignKey()) {
+        if (!field.isUni1ToMFK()) {
             row = rm.getSecondaryRow(field.getTable(), Row.ACTION_INSERT);
             row.setForeignKey(field.getJoinForeignKey(), field.getJoinColumnIO(),
                 sm);
@@ -264,7 +263,7 @@ public class RelationRelationMapTableFie
             entry = (Map.Entry) itr.next();
             keysm = RelationStrategies.getStateManager(entry.getKey(), ctx);
             valsm = RelationStrategies.getStateManager(entry.getValue(), ctx);
-            if (field.isUnidirectionalOneToManyForeignKey()){
+            if (field.isUni1ToMFK()){
                 row = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                     Row.ACTION_UPDATE, valsm, true);
                 row.wherePrimaryKey(valsm);
@@ -282,14 +281,14 @@ public class RelationRelationMapTableFie
             // from the view point of the owned side
             PersistenceCapable obj = sm.getPersistenceCapable();
             if (!populateKey(row, valsm, obj, ctx, rm, store))
-                if (!field.isUnidirectionalOneToManyForeignKey())
+                if (!field.isUni1ToMFK())
                     rm.flushSecondaryRow(row);
         }
     }
 
     public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if (field.getMappedBy() != null && !field.isBidirectionalManyToOneJoinTable())
+        if (field.getMappedBy() != null && !field.isBiMTo1JT())
             return;
         
         Map map = (Map) sm.fetchObject(field.getIndex());
@@ -320,7 +319,7 @@ public class RelationRelationMapTableFie
         Object mkey;
         if (canChange && !change.isEmpty()) {
             Row changeRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 changeRow = rm.getSecondaryRow(field.getTable(),
                     Row.ACTION_UPDATE);
                 changeRow.whereForeignKey(field.getJoinForeignKey(), sm);
@@ -340,7 +339,7 @@ public class RelationRelationMapTableFie
                 keysm = RelationStrategies.getStateManager(mkey, ctx);
                 valsm = RelationStrategies.getStateManager(mval, ctx);
                 key.whereForeignKey(changeRow, keysm);
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     changeRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                         Row.ACTION_UPDATE, valsm, true);
                     changeRow.wherePrimaryKey(valsm);
@@ -356,7 +355,7 @@ public class RelationRelationMapTableFie
         Collection rem = ct.getRemoved();
         if (!rem.isEmpty() || (!canChange && !change.isEmpty())) {
             Row delRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 delRow = rm.getSecondaryRow(field.getTable(),
                     Row.ACTION_DELETE);
                 delRow.whereForeignKey(field.getJoinForeignKey(), sm);
@@ -364,7 +363,7 @@ public class RelationRelationMapTableFie
 
             for (Iterator itr = rem.iterator(); itr.hasNext();) {
                 Object pc = itr.next();
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     updateSetNull(sm, rm, pc);
                 } else {
                     keysm = RelationStrategies.getStateManager(pc, ctx);
@@ -375,7 +374,7 @@ public class RelationRelationMapTableFie
             if (!canChange && !change.isEmpty()) {
                 for (Iterator itr = change.iterator(); itr.hasNext();) {
                     Object pc = itr.next();
-                    if (field.isUnidirectionalOneToManyForeignKey()){
+                    if (field.isUni1ToMFK()){
                         updateSetNull(sm, rm, pc);
                     } else { 
                         keysm = RelationStrategies.getStateManager(pc, ctx);
@@ -390,7 +389,7 @@ public class RelationRelationMapTableFie
         Collection add = ct.getAdded();
         if (!add.isEmpty() || (!canChange && !change.isEmpty())) {
             Row addRow = null;
-            if (!field.isUnidirectionalOneToManyForeignKey()) {
+            if (!field.isUni1ToMFK()) {
                 addRow = rm.getSecondaryRow(field.getTable(),
                     Row.ACTION_INSERT);
                 addRow.setForeignKey(field.getJoinForeignKey(),
@@ -410,7 +409,7 @@ public class RelationRelationMapTableFie
                     continue;
                 keysm = RelationStrategies.getStateManager(mkey, ctx);
                 valsm = RelationStrategies.getStateManager(mval, ctx);
-                if (field.isUnidirectionalOneToManyForeignKey()){
+                if (field.isUni1ToMFK()){
                     addRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                         Row.ACTION_UPDATE, valsm, true);
                     addRow.wherePrimaryKey(valsm);
@@ -437,7 +436,7 @@ public class RelationRelationMapTableFie
                         continue;
                     keysm = RelationStrategies.getStateManager(mkey, ctx);
                     valsm = RelationStrategies.getStateManager(mval, ctx);
-                    if (field.isUnidirectionalOneToManyForeignKey()){
+                    if (field.isUni1ToMFK()){
                         addRow = rm.getRow(field.getElementMapping().getDeclaredTypeMapping().getTable(),
                             Row.ACTION_UPDATE, valsm, true);
                         addRow.wherePrimaryKey(valsm);
@@ -504,7 +503,7 @@ public class RelationRelationMapTableFie
     
     public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if (field.isUnidirectionalOneToManyForeignKey()) {
+        if (field.isUni1ToMFK()) {
             Map mapObj = (Map)sm.fetchObject(field.getIndex());
             updateSetNull(sm, store, rm, mapObj.keySet());
             return;

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java?rev=1243702&r1=1243701&r2=1243702&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyTableFieldStrategy.java Mon Feb 13 21:23:54 2012
@@ -113,7 +113,7 @@ public abstract class RelationToManyTabl
         // Bi-directional oneToMany relation with join table strategy
         // ==> should not mapped in the owner's table
         if (mapped != null) {
-            if (!field.isBidirectionalManyToOneJoinTable()) {
+            if (!field.isBiMTo1JT()) {
                 if (mapped.getElement().getTypeCode() != JavaTypes.PC) {
                     throw new MetaDataException(_loc.get("not-inv-relation-coll",
                             field, mapped));
@@ -134,9 +134,9 @@ public abstract class RelationToManyTabl
             }
         }
 
-        if (mapped == null || field.isBidirectionalManyToOneJoinTable()) {
-            if (field.isBidirectionalManyToOneJoinTable())
-                field.setBidirectionalOneToManyJoinTableInfo();
+        if (mapped == null || field.isBiMTo1JT()) {
+            if (field.isBiMTo1JT())
+                field.setBi1MJoinTableInfo();
             field.mapJoin(adapt, true);
             if (elem.getTypeMapping().isMapped()) {
                 ForeignKey fk = vinfo.getTypeJoin(elem, "element", false, adapt);
@@ -157,7 +157,7 @@ public abstract class RelationToManyTabl
 
     public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if (field.getMappedBy() == null || field.isBidirectionalManyToOneJoinTable()) 
+        if (field.getMappedBy() == null || field.isBiMTo1JT()) 
             insert(sm, rm, sm.fetchObject(field.getIndex()));
     }
 
@@ -188,7 +188,7 @@ public abstract class RelationToManyTabl
 
     public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
         throws SQLException {
-        if (field.getMappedBy() != null && !field.isBidirectionalManyToOneJoinTable())
+        if (field.getMappedBy() != null && !field.isBiMTo1JT())
             return;
 
         Object obj = sm.fetchObject(field.getIndex());



Mime
View raw message