diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java index 0b6c11096..130e97fa4 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCachePCDataImpl.java @@ -168,7 +168,8 @@ public class DataCachePCDataImpl .indexOf(fmd.getName()) != -1) { DataCache cache = sm.getMetaData().getDataCache(); Object oid = sm.getContext().getObjectId(sm.fetch(i)); - DataCachePCData data = cache.get(oid); + DataCachePCData data = cache == null ? null + : cache.get(oid); if ((data != null) && (data instanceof DataCachePCDataImpl)) { ((DataCachePCDataImpl) data) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java index 271c3c105..da65baa92 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/QueryCacheStoreQuery.java @@ -128,6 +128,9 @@ public class QueryCacheStoreQuery // using it because of the individual by-oid lookups ClassMetaData meta = _repos.getMetaData(getContext(). getCandidateType(), _sctx.getClassLoader(), true); + if (meta.getDataCache() == null) + return null; + BitSet idxs = meta.getDataCache().containsAll(res); // eventually we should optimize this to figure out how many objects @@ -333,9 +336,11 @@ public class QueryCacheStoreQuery (q.getContext(), classes)); // evict from the data cache - for (int i = 0; i < cmd.length; i++) - cmd[i].getDataCache().removeAll( - cmd[i].getDescribedType(), true); + for (int i = 0; i < cmd.length; i++) { + if (cmd[i].getDataCache() != null) + cmd[i].getDataCache().removeAll( + cmd[i].getDescribedType(), true); + } } public Number executeDelete(StoreQuery q, Object[] params) {