OPENJPA-1485: fix potential classCast exception for StateManagerImpl

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@903964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2010-01-28 05:53:47 +00:00
parent 4197457c85
commit 54ef07f799
1 changed files with 7 additions and 1 deletions

View File

@ -162,7 +162,7 @@ public class OpenJPAPersistenceUtil {
if (fmds != null && fmds.length > 0) {
pcs = addToLoadSet(pcs, sm);
for (FieldMetaData fmd : fmds) {
if (((StateManagerImpl)sm).requiresFetch(fmd)) {
if (requiresFetch(sm, fmd)) {
if (!isLoadedField(sm, fmd, pcs)) {
isLoaded = false;
break;
@ -179,6 +179,12 @@ public class OpenJPAPersistenceUtil {
return isLoaded ? LoadState.LOADED : LoadState.NOT_LOADED;
}
private static boolean requiresFetch(OpenJPAStateManager sm, FieldMetaData fmd) {
if (sm instanceof StateManagerImpl)
return ((StateManagerImpl)sm).requiresFetch(fmd);
return fmd.isInDefaultFetchGroup();
}
/*
* Returns true if the field is a collection type and it was explicitly
* set to null.