diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java index 500a6efb2..e9cd0905b 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderCacheImpl.java @@ -60,8 +60,7 @@ public class FinderCacheImpl // Key: class name Value: Reason why excluded private final Map _uncachables; private List _exclusionPatterns; - private QueryStatistics> - _stats; + private QueryStatistics _stats; private ReentrantLock _lock = new ReentrantLock(); private Log _log; private Localizer _loc = Localizer.forPackage(FinderCacheImpl.class); @@ -71,8 +70,7 @@ public class FinderCacheImpl _delegate = new HashMap>(); _uncachables = new HashMap(); - _stats = new QueryStatistics.Default>(); + _stats = new QueryStatistics.Default(); } /** @@ -96,8 +94,7 @@ public class FinderCacheImpl /** * Gets basic statistics of execution and hit count of finder queries. */ - public QueryStatistics> - getStatistics() { + public QueryStatistics getStatistics() { return _stats; } @@ -121,7 +118,7 @@ public class FinderCacheImpl return null; FinderQuery result = _delegate.get(mapping); - _stats.recordExecution(result, result != null); + _stats.recordExecution(mapping, result != null); return result; } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java index 59ab87d90..96a9064a9 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java @@ -36,6 +36,7 @@ import org.apache.openjpa.kernel.FetchConfiguration; import org.apache.openjpa.kernel.FinderQuery; import org.apache.openjpa.kernel.OpenJPAStateManager; import org.apache.openjpa.kernel.StoreManager; +import org.apache.openjpa.meta.FieldMetaData; import org.apache.openjpa.util.ApplicationIds; import org.apache.openjpa.util.Id; @@ -55,6 +56,7 @@ public class FinderQueryImpl private final SelectImpl _select; private final Column[] _pkCols; private final Joinable[] _joins; + private final int[] _pkIndices; private final SQLBuffer _buffer; private final String _sql; @@ -86,6 +88,12 @@ public class FinderQueryImpl _joins = new Joinable[_pkCols.length]; for (int i = 0; i < _pkCols.length; i++) _joins[i] = _mapping.assertJoinable(_pkCols[i]); + _pkIndices = new int[_pkCols.length]; + for (int i = 0; i < _pkCols.length; i++) { + FieldMetaData pk = _mapping.getField(_joins[i].getFieldIndex()); + _pkIndices[i] = pk == null ? 0 : pk.getPrimaryKeyIndex(); + } + } public ClassMapping getIdentifier() { @@ -111,12 +119,10 @@ public class FinderQueryImpl for (int i = 0; i < _pkCols.length; i++, count++) { if (pks == null) val[0] = (oid == null) - ? null - : Numbers.valueOf(((Id) oid).getId()); + ? null : Numbers.valueOf(((Id) oid).getId()); else { - val[i] = pks[_mapping.getField(_joins[i].getFieldIndex()). - getPrimaryKeyIndex()]; - val[i] = _joins[i].getJoinValue(val[i], _pkCols[i], store); + val[i] = _joins[i].getJoinValue(pks[_pkIndices[i]], _pkCols[i], + store); } } return val; diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java index d7a10545c..d76fc9f20 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ManagedClassSubclasser.java @@ -203,7 +203,8 @@ public class ManagedClassSubclasser { private static Set collectUnspecifiedType(Class cls, Collection classes, Set unspecified) { if (cls != null && !classes.contains(cls) - && !ImplHelper.isManagedType(null, cls)) { + && !ImplHelper.isManagedType(null, cls) + && !cls.isInterface()) { if (unspecified == null) unspecified = new HashSet(); unspecified.add(cls); diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FinderCache.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FinderCache.java index 20ae82fe8..0c4bc7716 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FinderCache.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FinderCache.java @@ -140,5 +140,5 @@ public interface FinderCache extends Configurable { /** * Gets the simple statistics for executed finder queries. */ - public QueryStatistics> getStatistics(); + public QueryStatistics getStatistics(); } \ No newline at end of file