openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1662611 - in /openjpa/branches/2.2.1.x: ./ 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:26:27 GMT
Author: hthomann
Date: Fri Feb 27 01:26:27 2015
New Revision: 1662611

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

Added:
    openjpa/branches/2.2.1.x/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/branches/2.2.1.x/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/branches/2.2.1.x/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/branches/2.2.1.x/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/branches/2.2.1.x/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/branches/2.2.1.x/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/branches/2.2.1.x/   (props changed)
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java

Propchange: openjpa/branches/2.2.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 27 01:26:27 2015
@@ -1,5 +1,5 @@
 /openjpa/branches/1.0.x:736493
 /openjpa/branches/2.0.x:1419659,1484136,1484287,1504611
-/openjpa/branches/2.1.x:1415379,1415398,1436150,1469090,1469949,1484300,1484313,1485010,1505837,1513249,1517838,1529241,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1614935,1636464,1648430,1655218
+/openjpa/branches/2.1.x:1415379,1415398,1436150,1469090,1469949,1484300,1484313,1485010,1505837,1513249,1517838,1529241,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1614935,1636464,1648430,1655218,1662610
 /openjpa/branches/2.2.x:1580898,1580939,1591681
 /openjpa/trunk:1416742,1420324,1430117,1431649,1436957,1436960,1448662,1448796,1451369,1456574,1456614,1459091,1461833,1469646,1469649,1469652,1504282,1600757,1603251

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java?rev=1662611&r1=1662610&r2=1662611&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
Fri Feb 27 01:26:27 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