OPENJPA-2539: Query Compilation causing inner join table to be randomly generated incorrectly - ported changes to trunk.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1686913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Heath Thomann 2015-06-22 18:31:06 +00:00
parent ea1682c425
commit 856fefb2c8
1 changed files with 16 additions and 9 deletions

View File

@ -632,9 +632,9 @@ public class QueryImpl
* Find the cached compilation for the current query, creating one if it
* does not exist.
*/
@SuppressWarnings("unchecked")
protected Compilation compilationFromCache() {
Map compCache =
_broker.getConfiguration().getQueryCompilationCacheInstance();
Map compCache = _broker.getConfiguration().getQueryCompilationCacheInstance();
if (compCache == null || !isParsedQuery()) {
return newCompilation();
} else {
@ -648,17 +648,24 @@ public class QueryImpl
Compilation comp = (Compilation) compCache.get(key);
// parse declarations if needed
boolean cache = false;
if (comp == null) {
comp = newCompilation();
// only cache those queries that can be compiled
cache = comp.storeData != null;
} else
_storeQuery.populateFromCompilation(comp.storeData);
if (comp.storeData != null) {
synchronized (compCache) {
Compilation existingComp = (Compilation) compCache.get(key);
if (existingComp == null) {
compCache.put(key, comp);
} else {
comp = existingComp;
}
}
}
} else {
_storeQuery.populateFromCompilation(comp.storeData);
}
// cache parsed state if needed
if (cache)
compCache.put(key, comp);
return comp;
}
}