openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1662615 - in /openjpa/trunk: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/
Date Fri, 27 Feb 2015 01:44:10 GMT
Author: hthomann
Date: Fri Feb 27 01:44:09 2015
New Revision: 1662615

URL: http://svn.apache.org/r1662615
Log:
OPENJPA-2557: FinderCache contains incorrectly cached query with a NULL for a Primary Key.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/
      - copied from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/AbstractExtValue.java
      - copied unchanged from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/AbstractExtValue.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/ComposedPK.java
      - copied unchanged from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/ComposedPK.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/ExtValue1.java
      - copied unchanged from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/ExtValue1.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/TestFinderCacheWithNulls.java
      - copied unchanged from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/TestFinderCacheWithNulls.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/UserData.java
      - copied unchanged from r1662610, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/discrim/UserData.java
Modified:
    openjpa/trunk/   (props changed)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java

Propchange: openjpa/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 27 01:44:09 2015
@@ -1,6 +1,6 @@
 /openjpa/branches/1.0.x:736493
 /openjpa/branches/2.0.x:1504611
-/openjpa/branches/2.1.x:1415379,1415398,1485010,1513249,1517838,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1636464,1655218
+/openjpa/branches/2.1.x:1415379,1415398,1485010,1513249,1517838,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1636464,1655218,1662610
 /openjpa/branches/2.2.1.x:1415367,1415413,1415425,1504719,1508186,1530347,1533222,1539193,1651808
 /openjpa/branches/2.2.x:1384400,1415459-1415460,1415469,1485013,1530364,1533223,1580898,1580939,1591681,1631786
 /openjpa/branches/2.3.x:1533462,1535560,1564121

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java?rev=1662615&r1=1662614&r2=1662615&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
Fri Feb 27 01:44:09 2015
@@ -72,7 +72,17 @@ public class FinderQueryImpl
             return null;
         SQLBuffer buffer = impl.getSQL();
         Column[] pkCols = mapping.getPrimaryKeyColumns();
-        boolean canCache = pkCols.length == buffer.getParameters().size();
+
+        //OPENJPA-2557: Typically the number of pkCols (length) should match the number (size)
of 
+        //parameters.  However, there are a few cases (e.g. when extra parameters are needed
for
+        //discriminator data) where the pkCols length may be different than the parameters.
  
+        //If we find the number of pkCols is equal to the number of parameters, we need to
do
+        //one last check to verify that the buffers columns match the pkCols exactly.
+        boolean canCache = (pkCols.length == buffer.getParameters().size());
+        for(int i=0; i < pkCols.length  && canCache; i++){
+            canCache = canCache && buffer.getColumns().contains(pkCols[i]);     
      
+        }
+        
         return (canCache)
             ? new FinderQueryImpl(mapping, impl, buffer) : null;
     }



Mime
View raw message