diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java index 1791c95f0..9187e5374 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java @@ -816,7 +816,7 @@ public class FetchConfigurationImpl if (!includes(fm)) return FETCH_NONE; - Class type = getRelationType(fm); + Class type = fm.getRelationType(); if (type == null) return FETCH_LOAD; if (_availableDepth == 0) @@ -842,7 +842,7 @@ public class FetchConfigurationImpl } public FetchConfiguration traverse(FieldMetaData fm) { - Class type = getRelationType(fm); + Class type = fm.getRelationType(); if (type == null) return this; @@ -943,18 +943,6 @@ public class FetchConfigurationImpl return Math.min(max, avail); } - /** - * Return the relation type of the given field. - */ - private static Class getRelationType(FieldMetaData fm) { - if (fm.isDeclaredTypePC()) - return fm.getDeclaredType(); - if (fm.getElement().isDeclaredTypePC()) - return fm.getElement().getDeclaredType(); - if (fm.getKey().isDeclaredTypePC()) - return fm.getKey().getDeclaredType(); - return null; - } /** * Reduce the given logical depth by 1. diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java index 87fc8194d..1d666a057 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java @@ -2390,5 +2390,19 @@ public class FieldMetaData public void setPersistentCollection(boolean persistentCollection) { _persistentCollection = persistentCollection; } - + private Class _relationType = Unknown.class; + public Class getRelationType() { + if (_relationType == Unknown.class) { + if (isDeclaredTypePC()) + _relationType = getDeclaredType(); + else if (getElement().isDeclaredTypePC()) + _relationType = getElement().getDeclaredType(); + else if (getKey().isDeclaredTypePC()) + _relationType = getKey().getDeclaredType(); + else + _relationType = null; + } + return _relationType; + } + private class Unknown{}; } diff --git a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java index 237717916..59b44ef0f 100644 --- a/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java +++ b/openjpa-lib/src/main/java/org/apache/openjpa/lib/identifier/IdentifierUtilImpl.java @@ -542,7 +542,8 @@ public class IdentifierUtilImpl implements IdentifierUtil, Configurable { protected boolean needsConversion(IdentifierConfiguration config) { - return !(config.getConversionKey().equals(getIdentifierConfiguration().getConversionKey())); + return (config != getIdentifierConfiguration()) + && !(config.getConversionKey().equals(getIdentifierConfiguration().getConversionKey())); } private IdentifierRule[] getNamingRules(String[] rules) {