openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1533222 - in /openjpa/branches/2.2.1.x: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inher...
Date Thu, 17 Oct 2013 19:23:35 GMT
Author: hthomann
Date: Thu Oct 17 19:23:34 2013
New Revision: 1533222

URL: http://svn.apache.org/r1533222
Log:
OPENJPA-2343: Version field returns null when explicity projected from a JOIN in SELECT clause
- based fix off of patch provided by Howard Kelsey.  Merged 2.1.x commit to 2.2.1.x.

Added:
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/
      - copied from r1533218, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/Author.java
      - copied unchanged from r1533218, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/Author.java
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/Document.java
      - copied unchanged from r1533218, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/Document.java
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/TestJoinVersionField.java
      - copied unchanged from r1533218, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jpql/version/TestJoinVersionField.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/meta/FieldMapping.java
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
    openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
    openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany/
  (props changed)

Propchange: openjpa/branches/2.2.1.x/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x:r1533218

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java?rev=1533222&r1=1533221&r2=1533222&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
Thu Oct 17 19:23:34 2013
@@ -1006,7 +1006,7 @@ public class FieldMapping
     	// OPENJPA-662: Version fields have NoneFieldStrategy -- hence they
     	// need special treatment
     	if (isVersion()) {
-    		return getDefiningMapping().getVersion().load(null, store, res);
+    		return getDefiningMapping().getVersion().load(null, store, res, joins);
     	}
         return assertStrategy().loadProjection(store, fetch, res, joins);
     }

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java?rev=1533222&r1=1533221&r2=1533222&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
Thu Oct 17 19:23:34 2013
@@ -26,6 +26,7 @@ import org.apache.openjpa.jdbc.schema.Co
 import org.apache.openjpa.jdbc.schema.ColumnIO;
 import org.apache.openjpa.jdbc.schema.Index;
 import org.apache.openjpa.jdbc.schema.Schemas;
+import org.apache.openjpa.jdbc.sql.Joins;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.RowManager;
 import org.apache.openjpa.jdbc.sql.Select;
@@ -343,6 +344,11 @@ public class Version
         return assertStrategy().load(sm, store, res);
     }
 
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins)
+        throws SQLException {
+        return assertStrategy().load(sm, store, res, joins);
+    }
+    
     public void afterLoad(OpenJPAStateManager sm, JDBCStore store) {
         assertStrategy().afterLoad(sm, store);
     }

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java?rev=1533222&r1=1533221&r2=1533222&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
Thu Oct 17 19:23:34 2013
@@ -23,6 +23,7 @@ import java.util.Map;
 
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.sql.Joins;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
@@ -55,6 +56,12 @@ public interface VersionStrategy
      */
     public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
         throws SQLException;
+    
+    /**
+     * Load data.
+     */
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins)
+        throws SQLException;
 
     /**
      * This method is called after data is loaded into the instance, in

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java?rev=1533222&r1=1533221&r2=1533222&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
Thu Oct 17 19:23:34 2013
@@ -19,13 +19,14 @@
 package org.apache.openjpa.jdbc.meta.strats;
 
 import java.sql.SQLException;
-import java.util.Map;
 import java.util.Collections;
+import java.util.Map;
 
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.Version;
 import org.apache.openjpa.jdbc.meta.VersionStrategy;
+import org.apache.openjpa.jdbc.sql.Joins;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.Select;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
@@ -58,6 +59,11 @@ public abstract class AbstractVersionStr
     	return null;
     }
 
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins)
+        throws SQLException {
+        return null;
+    }
+    
     public void afterLoad(OpenJPAStateManager sm, JDBCStore store) {
     }
 

Modified: openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java?rev=1533222&r1=1533221&r2=1533222&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
(original)
+++ openjpa/branches/2.2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
Thu Oct 17 19:23:34 2013
@@ -29,11 +29,13 @@ import org.apache.openjpa.jdbc.kernel.JD
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.VersionMappingInfo;
+import org.apache.openjpa.jdbc.meta.strats.AbstractVersionStrategy;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.ColumnIO;
 import org.apache.openjpa.jdbc.schema.ForeignKey;
 import org.apache.openjpa.jdbc.schema.Index;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.Joins;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.Row;
 import org.apache.openjpa.jdbc.sql.RowManager;
@@ -258,17 +260,22 @@ public abstract class ColumnVersionStrat
         sel.select(vers.getColumns());
         return true;
     }
+    
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res) 
+        throws SQLException {
+        return this.load(sm, store, res, null);
+    }
 
-    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res, Joins joins)
         throws SQLException {
         // typically if one version column is in the result, they all are, so
         // optimize by checking for the first one before doing any real work
         Column[] cols = vers.getColumns();
-        if (!res.contains(cols[0])) {
+        if (!res.contains(cols[0], joins)) {
             return null;
         }
 
-        Object version = populateFromResult(res);
+        Object version = populateFromResult(res, joins);
         
         // OPENJPA-662 Allow a null StateManager because this method may just be
         // invoked to get the result of projection query
@@ -298,7 +305,7 @@ public abstract class ColumnVersionStrat
                 return false;
 
             Object memVersion = sm.getVersion();
-            Object dbVersion  = populateFromResult(res);
+            Object dbVersion  = populateFromResult(res, null);
             boolean refresh   = compare(memVersion, dbVersion) < 0;
 
             if (updateVersion)
@@ -329,14 +336,14 @@ public abstract class ColumnVersionStrat
      * @return a single Object or an array depending on whether using a single
      * or multiple columns being used for representation.
     */
-    Object populateFromResult(Result res) throws SQLException {
+    Object populateFromResult(Result res, Joins joins) throws SQLException {
         if (res == null)
  		return null;
     	
         Column[] cols = vers.getColumns();
         Object[] values = new Object[cols.length];
         for (int i = 0; i < cols.length; i++) {
-            values[i] = res.getObject(cols[i], -1, null);
+            values[i] = res.getObject(cols[i], null, joins);
         }
         return (cols.length == 1) ? values[0] : values;
     }

Propchange: openjpa/branches/2.2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany/
------------------------------------------------------------------------------
  Merged /openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/onetomany:r1533218



Mime
View raw message