openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtyle...@apache.org
Subject svn commit: r782346 - in /openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: meta/strats/ sql/
Date Sun, 07 Jun 2009 08:27:05 GMT
Author: mtylenda
Date: Sun Jun  7 08:27:05 2009
New Revision: 782346

URL: http://svn.apache.org/viewvc?rev=782346&view=rev
Log:
OPENJPA-1122: Remove JDBC 3 related reflection from DBDictionary

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java
Sun Jun  7 08:27:05 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.meta.strats;
 
+import java.sql.Blob;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -89,7 +90,7 @@
         DBDictionary dict)
         throws SQLException {
         byte[] b = (byte[]) sm.setImplData(field.getIndex(), null);
-        Object blob = rs.getBlob(1);
+        Blob blob = rs.getBlob(1);
         dict.putBytes(blob, b);
     }
 

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java
Sun Jun  7 08:27:05 2009
@@ -19,6 +19,7 @@
 package org.apache.openjpa.jdbc.meta.strats;
 
 import java.lang.reflect.Array;
+import java.sql.Blob;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -72,7 +73,7 @@
     protected void putData(OpenJPAStateManager sm, ResultSet rs,
         DBDictionary dict)
         throws SQLException {
-        Object blob = rs.getBlob(1);
+        Blob blob = rs.getBlob(1);
         dict.putBytes(blob, PrimitiveWrapperArrays.toByteArray(sm.fetchObject
             (field.getIndex())));
     }
@@ -80,7 +81,7 @@
     protected Object load(Column col, Result res, Joins joins)
         throws SQLException {
         return PrimitiveWrapperArrays.toObjectValue(field,
-            (byte[]) res.getBytes(col, joins));
+            res.getBytes(col, joins));
     }
 
     public void map(boolean adapt) {

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java
Sun Jun  7 08:27:05 2009
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.io.Reader;
 import java.lang.reflect.Array;
+import java.sql.Clob;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -77,7 +78,7 @@
     protected void putData(OpenJPAStateManager sm, ResultSet rs,
         DBDictionary dict)
         throws SQLException {
-        Object clob = rs.getClob(1);
+        Clob clob = rs.getClob(1);
         dict.putChars(clob, PrimitiveWrapperArrays.
             toCharArray(sm.fetchObject(field.getIndex())));
     }

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java
Sun Jun  7 08:27:05 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.meta.strats;
 
+import java.sql.Clob;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -66,7 +67,7 @@
     protected void putData(OpenJPAStateManager sm, ResultSet rs,
         DBDictionary dict)
         throws SQLException {
-        Object clob = rs.getClob(1);
+        Clob clob = rs.getClob(1);
         dict.putString(clob, sm.fetchString(field.getIndex()));
     }
 

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Sun Jun  7 08:27:05 2009
@@ -28,8 +28,6 @@
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Array;
@@ -371,11 +369,6 @@
     // first time it happens we can warn the user
     private Set _precisionWarnedTypes = null;
 
-    // cache lob methods
-    private Method _setBytes = null;
-    private Method _setString = null;
-    private Method _setCharStream = null;
-
     // batchLimit value:
     // -1 = unlimited
     // 0  = no batch
@@ -1394,55 +1387,27 @@
     /**
      * Invoke the JDK 1.4 <code>setBytes</code> method on the given BLOB object.
      */
-    public void putBytes(Object blob, byte[] data)
+    public void putBytes(Blob blob, byte[] data)
         throws SQLException {
-        if (_setBytes == null) {
-            try {
-                _setBytes = blob.getClass().getMethod("setBytes",
-                    new Class[]{ long.class, byte[].class });
-            } catch (Exception e) {
-                throw new StoreException(e);
-            }
-        }
-        invokePutLobMethod(_setBytes, blob,
-            new Object[]{ Numbers.valueOf(1L), data });
+        blob.setBytes(1L, data);
     }
 
     /**
      * Invoke the JDK 1.4 <code>setString</code> method on the given CLOB
      * object.
      */
-    public void putString(Object clob, String data)
+    public void putString(Clob clob, String data)
         throws SQLException {
-        if (_setString == null) {
-            try {
-                _setString = clob.getClass().getMethod("setString",
-                    new Class[]{ long.class, String.class });
-            } catch (Exception e) {
-                throw new StoreException(e);
-            }
-        }
-        invokePutLobMethod(_setString, clob,
-            new Object[]{ Numbers.valueOf(1L), data });
+        clob.setString(1L, data);
     }
 
     /**
      * Invoke the JDK 1.4 <code>setCharacterStream</code> method on the given
      * CLOB object.
      */
-    public void putChars(Object clob, char[] data)
+    public void putChars(Clob clob, char[] data)
         throws SQLException {
-        if (_setCharStream == null) {
-            try {
-                _setCharStream = clob.getClass().getMethod
-                    ("setCharacterStream", new Class[]{ long.class });
-            } catch (Exception e) {
-                throw new StoreException(e);
-            }
-        }
-
-        Writer writer = (Writer) invokePutLobMethod(_setCharStream, clob,
-            new Object[]{ Numbers.valueOf(1L) });
+        Writer writer = clob.setCharacterStream(1L);
         try {
             writer.write(data);
             writer.flush();
@@ -1452,24 +1417,6 @@
     }
 
     /**
-     * Invoke the given LOB method on the given target with the given data.
-     */
-    private static Object invokePutLobMethod(Method method, Object target,
-        Object[] args)
-        throws SQLException {
-        try {
-            return method.invoke(target, args);
-        } catch (InvocationTargetException ite) {
-            Throwable t = ite.getTargetException();
-            if (t instanceof SQLException)
-                throw(SQLException) t;
-            throw new StoreException(t);
-        } catch (Exception e) {
-            throw new StoreException(e);
-        }
-    }
-
-    /**
      * Warn that a particular value could not be stored precisely.
      * After the first warning for a particular type, messages
      * will be turned into trace messages.

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=782346&r1=782345&r2=782346&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
Sun Jun  7 08:27:05 2009
@@ -937,7 +937,7 @@
      * vendor-specific class; for example Weblogic wraps oracle thin driver
      * lobs in its own interfaces with the same methods.
      */
-    public void putBytes(Object blob, byte[] data)
+    public void putBytes(Blob blob, byte[] data)
         throws SQLException {
         if (blob == null)
             return;
@@ -958,7 +958,7 @@
      * vendor-specific class; for example Weblogic wraps oracle thin driver
      * lobs in its own interfaces with the same methods.
      */
-    public void putString(Object clob, String data)
+    public void putString(Clob clob, String data)
         throws SQLException {
         if (_putString == null) {
             try {
@@ -977,7 +977,7 @@
      * vendor-specific class; for example Weblogic wraps oracle thin driver
      * lobs in its own interfaces with the same methods.
      */
-    public void putChars(Object clob, char[] data)
+    public void putChars(Clob clob, char[] data)
         throws SQLException {
         if (_putChars == null) {
             try {



Mime
View raw message