openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r677704 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta: FieldMapping.java Version.java VersionStrategy.java strats/AbstractVersionStrategy.java strats/ColumnVersionStrategy.java
Date Thu, 17 Jul 2008 20:11:43 GMT
Author: ppoddar
Date: Thu Jul 17 13:11:42 2008
New Revision: 677704

URL: http://svn.apache.org/viewvc?rev=677704&view=rev
Log:
OPENJPA-662: Allow version field values be loaded in projection query

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java?rev=677704&r1=677703&r2=677704&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/FieldMapping.java
Thu Jul 17 13:11:42 2008
@@ -880,6 +880,11 @@
     public Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch,
         Result res, Joins joins)
         throws SQLException {
+    	// OPENJPA-662: Version fields have NoneFieldStrategy -- hence they
+    	// need special treatment
+    	if (isVersion()) {
+    		return getDefiningMapping().getVersion().load(null, store, res);
+    	}
         return assertStrategy().loadProjection(store, fetch, res, joins);
     }
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java?rev=677704&r1=677703&r2=677704&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/Version.java Thu
Jul 17 13:11:42 2008
@@ -338,9 +338,9 @@
         return assertStrategy().select(sel, mapping);
     }
 
-    public void load(OpenJPAStateManager sm, JDBCStore store, Result res)
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
         throws SQLException {
-        assertStrategy().load(sm, store, res);
+        return assertStrategy().load(sm, store, res);
     }
 
     public void afterLoad(OpenJPAStateManager sm, JDBCStore store) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java?rev=677704&r1=677703&r2=677704&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionStrategy.java
Thu Jul 17 13:11:42 2008
@@ -53,7 +53,7 @@
     /**
      * Load data.
      */
-    public void load(OpenJPAStateManager sm, JDBCStore store, Result res)
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
         throws SQLException;
 
     /**

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java?rev=677704&r1=677703&r2=677704&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/AbstractVersionStrategy.java
Thu Jul 17 13:11:42 2008
@@ -53,8 +53,9 @@
         return false;
     }
 
-    public void load(OpenJPAStateManager sm, JDBCStore store, Result res)
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
         throws SQLException {
+    	return null;
     }
 
     public void afterLoad(OpenJPAStateManager sm, JDBCStore store) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java?rev=677704&r1=677703&r2=677704&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ColumnVersionStrategy.java
Thu Jul 17 13:11:42 2008
@@ -178,13 +178,13 @@
         return true;
     }
 
-    public void load(OpenJPAStateManager sm, JDBCStore store, Result res)
+    public Object load(OpenJPAStateManager sm, JDBCStore store, Result res)
         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]))
-            return;
+            return null;
 
         Object version = null;
         if (cols.length > 0)
@@ -192,14 +192,18 @@
         Object cur;
         for (int i = 0; i < cols.length; i++) {
             if (i > 0 && !res.contains(cols[i]))
-                return;
+                return null;
             cur = res.getObject(cols[i], -1, null);
             if (cols.length == 1)
                 version = cur;
             else
                 ((Object[]) version)[i] = cur;
         }
-        sm.setVersion(version);
+        // OPENJPA-662 Allow a null StateManager because this method may just be
+        // invoked to get the result of projection query
+        if (sm != null)
+        	sm.setVersion(version);
+        return version;
     }
 
     public boolean checkVersion(OpenJPAStateManager sm, JDBCStore store,



Mime
View raw message