openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r746060 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.java
Date Thu, 19 Feb 2009 23:58:42 GMT
Author: ppoddar
Date: Thu Feb 19 23:58:42 2009
New Revision: 746060

URL: http://svn.apache.org/viewvc?rev=746060&view=rev
Log:
OPENJPA-924: Set JDBC query parameters with type information

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/FinderQueryImpl.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.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=746060&r1=746059&r2=746060&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
Thu Feb 19 23:58:42 2009
@@ -26,6 +26,7 @@
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.Joinable;
 import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.LogicalUnion;
 import org.apache.openjpa.jdbc.sql.Result;
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
@@ -131,18 +132,19 @@
     public Result execute(OpenJPAStateManager sm, StoreManager store, 
         FetchConfiguration fetch) {
         boolean forUpdate = false;
-        Connection conn = ((JDBCStore)store).getConnection();
+        JDBCStore jstore = (JDBCStore)store;
+        Connection conn = jstore.getConnection();
+        DBDictionary dict = jstore.getDBDictionary();
         PreparedStatement stmnt = null;
         ResultSet rs = null;
         try {
             stmnt = conn.prepareStatement(_sql);
-            Object[] params = getPKValues(sm, (JDBCStore)store);
-            int i = 0;
-            for (Object o : params) {
-                stmnt.setObject(++i, o);
+            Object[] params = getPKValues(sm, jstore);
+            for (int i = 0; i <params.length; i++) {
+                dict.setUnknown(stmnt, i+1, params[i], _pkCols[i]);
             }
             rs = stmnt.executeQuery();
-            return _select.getEagerResult(conn, stmnt, rs, (JDBCStore)store, 
+            return _select.getEagerResult(conn, stmnt, rs, jstore, 
                 (JDBCFetchConfiguration)fetch, forUpdate, _buffer);
         } catch (SQLException se) {
             if (stmnt != null)

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.java?rev=746060&r1=746059&r2=746060&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/sqlcache/TestFinderCache.java
Thu Feb 19 23:58:42 2009
@@ -27,6 +27,7 @@
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.kernel.FinderCache;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
@@ -35,7 +36,7 @@
  * @author Pinaki Poddar
  *
  */
-public class TestFinderCache extends SingleEMFTestCase {
+public class TestFinderCache extends SQLListenerTestCase {
     public static final long[] BOOK_IDS = {1000, 2000, 3000};
     public static final String[] BOOK_NAMES = {"Argumentative Indian", "Tin Drum", "Blink"};
     public static final long[] CD_IDS = {1001, 2001, 3001};
@@ -87,6 +88,20 @@
         System.err.println("delta   " + (pct > 0 ? "+" : "") + pct + "%");
     }
     
+    public void testSQLEventListener() {
+        EntityManager em = emf.createEntityManager();
+        int N = 3;
+        sql.clear();
+        for (int i = 0; i < N; i++) {
+            em.clear();
+            for (long id : BOOK_IDS) {
+                Book pc = em.find(Book.class, id);
+                assertNotNull(pc);
+            }
+        }
+        assertEquals(BOOK_IDS.length*N, sql.size());
+    }
+    
     /**
      * Run a finder query for each identifiers N times and report the median
      * execution time.



Mime
View raw message