Fix NPE reported on newsgroup.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@633739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2008-03-05 01:21:58 +00:00
parent f3dd4c0397
commit 126358f0e4
2 changed files with 10 additions and 4 deletions

View File

@ -168,7 +168,8 @@ public class DataCachePCDataImpl
.indexOf(fmd.getName()) != -1) { .indexOf(fmd.getName()) != -1) {
DataCache cache = sm.getMetaData().getDataCache(); DataCache cache = sm.getMetaData().getDataCache();
Object oid = sm.getContext().getObjectId(sm.fetch(i)); Object oid = sm.getContext().getObjectId(sm.fetch(i));
DataCachePCData data = cache.get(oid); DataCachePCData data = cache == null ? null
: cache.get(oid);
if ((data != null) && if ((data != null) &&
(data instanceof DataCachePCDataImpl)) { (data instanceof DataCachePCDataImpl)) {
((DataCachePCDataImpl) data) ((DataCachePCDataImpl) data)

View File

@ -128,6 +128,9 @@ public class QueryCacheStoreQuery
// using it because of the individual by-oid lookups // using it because of the individual by-oid lookups
ClassMetaData meta = _repos.getMetaData(getContext(). ClassMetaData meta = _repos.getMetaData(getContext().
getCandidateType(), _sctx.getClassLoader(), true); getCandidateType(), _sctx.getClassLoader(), true);
if (meta.getDataCache() == null)
return null;
BitSet idxs = meta.getDataCache().containsAll(res); BitSet idxs = meta.getDataCache().containsAll(res);
// eventually we should optimize this to figure out how many objects // eventually we should optimize this to figure out how many objects
@ -333,9 +336,11 @@ public class QueryCacheStoreQuery
(q.getContext(), classes)); (q.getContext(), classes));
// evict from the data cache // evict from the data cache
for (int i = 0; i < cmd.length; i++) for (int i = 0; i < cmd.length; i++) {
cmd[i].getDataCache().removeAll( if (cmd[i].getDataCache() != null)
cmd[i].getDescribedType(), true); cmd[i].getDataCache().removeAll(
cmd[i].getDescribedType(), true);
}
} }
public Number executeDelete(StoreQuery q, Object[] params) { public Number executeDelete(StoreQuery q, Object[] params) {