openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r751148 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/FinderQueryImpl.java sql/SelectImpl.java
Date Sat, 07 Mar 2009 00:40:53 GMT
Author: faywang
Date: Sat Mar  7 00:40:53 2009
New Revision: 751148

URL: http://svn.apache.org/viewvc?rev=751148&view=rev
Log:
OPENJPA-965: Open up FinderCacheImpl for jdbc and non-jdbc
like implementation

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java

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=751148&r1=751147&r2=751148&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
Sat Mar  7 00:40:53 2009
@@ -109,6 +109,10 @@
         return _sql;
     }
     
+    public Column[] getPKColumns() {
+        return _pkCols;
+    }
+    
     private Object[] getPKValues(OpenJPAStateManager sm, JDBCStore store) {
         Object[] pks = null;
         Object oid = sm.getObjectId();
@@ -138,12 +142,15 @@
         PreparedStatement stmnt = null;
         ResultSet rs = null;
         try {
-            stmnt = conn.prepareStatement(_sql);
+            stmnt = _select.prepareStatement(conn, _sql);
             Object[] params = getPKValues(sm, jstore);
-            for (int i = 0; i <params.length; i++) {
-                dict.setUnknown(stmnt, i+1, params[i], _pkCols[i]);
+            if (stmnt != null) {
+                for (int i = 0; i <params.length; i++) {
+                    dict.setUnknown(stmnt, i+1, params[i], _pkCols[i]);
+                }
             }
-            rs = stmnt.executeQuery();
+
+            rs = _select.executeQuery(conn, stmnt, this, jstore, params);
             return _select.getEagerResult(conn, stmnt, rs, jstore, 
                 (JDBCFetchConfiguration)fetch, forUpdate, _buffer);
         } catch (SQLException se) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=751148&r1=751147&r2=751148&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Sat
Mar  7 00:40:53 2009
@@ -43,6 +43,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.kernel.EagerFetchModes;
+import org.apache.openjpa.jdbc.kernel.FinderQueryImpl;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
 import org.apache.openjpa.jdbc.kernel.JDBCLockManager;
 import org.apache.openjpa.jdbc.kernel.JDBCStore;
@@ -441,6 +442,15 @@
     
     /**
      * This method is to provide override for non-JDBC or JDBC-like 
+     * implementation of preparing statement.
+     */
+    public PreparedStatement prepareStatement(Connection conn, 
+        String sql) throws SQLException {
+        return conn.prepareStatement(sql);
+    }    
+    
+    /**
+     * This method is to provide override for non-JDBC or JDBC-like 
      * implementation of setting query timeout.
      */
     protected void setTimeout(PreparedStatement stmnt, boolean forUpdate,
@@ -471,6 +481,16 @@
     
     /**
      * This method is to provide override for non-JDBC or JDBC-like 
+     * implementation of executing query.
+     */
+    public ResultSet executeQuery(Connection conn, PreparedStatement stmnt, 
+        FinderQueryImpl finder, JDBCStore store, Object[] params) 
+        throws SQLException {
+        return stmnt.executeQuery();
+    }
+
+    /**
+     * This method is to provide override for non-JDBC or JDBC-like 
      * implementation of getting count from the result set.
      */
     protected int getCount(ResultSet rs) throws SQLException {



Mime
View raw message