Author: hthomann
Date: Mon Jun 22 16:27:04 2015
New Revision: 1686894
URL: http://svn.apache.org/r1686894
Log:
OPENJPA-2539: Query Compilation causing inner join table to be randomly
generated incorrectly.
Modified:
openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
Modified:
openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java?rev=1686894&r1=1686893&r2=1686894&view=diff
==============================================================================
---
openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
(original)
+++
openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
Mon Jun 22 16:27:04 2015
@@ -633,9 +633,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 {
@@ -649,17 +649,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
+ 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;
}
}