You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2008/07/07 14:31:48 UTC

svn commit: r674467 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle: OracleAdapter.java OracleLOBBatchAction.java

Author: aadamchik
Date: Mon Jul  7 05:31:47 2008
New Revision: 674467

URL: http://svn.apache.org/viewvc?rev=674467&view=rev
Log:
CAY-1085 Use standard JDBC API for writing Oracle LOBs

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleLOBBatchAction.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java?rev=674467&r1=674466&r2=674467&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java Mon Jul  7 05:31:47 2008
@@ -113,6 +113,9 @@
         }
     }
 
+    /**
+     * @deprecated since 3.0, as a generic BLOB method is used to write BLOBs.
+     */
     public static Method getOutputStreamFromBlobMethod() {
         return outputStreamFromBlobMethod;
     }
@@ -150,6 +153,9 @@
         return false;
     }
 
+    /**
+     * @deprecated since 3.0, as a generic CLOB method is used to write CLOBs.
+     */
     public static Method getWriterFromClobMethod() {
         return writerFromClobMethod;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleLOBBatchAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleLOBBatchAction.java?rev=674467&r1=674466&r2=674467&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleLOBBatchAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleLOBBatchAction.java Mon Jul  7 05:31:47 2008
@@ -21,8 +21,6 @@
 
 import java.io.OutputStream;
 import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Connection;
@@ -91,9 +89,9 @@
         // may be different depending on whether LOBs are NULL or not..
 
         LOBBatchQueryWrapper selectQuery = new LOBBatchQueryWrapper(query);
-        List<DbAttribute> qualifierAttributes = selectQuery.getDbAttributesForLOBSelectQualifier();
+        List<DbAttribute> qualifierAttributes = selectQuery
+                .getDbAttributesForLOBSelectQualifier();
 
-     
         boolean isLoggable = QueryLogger.isLoggable();
 
         query.reset();
@@ -108,7 +106,11 @@
 
                 if (isLoggable) {
                     List bindings = queryBuilder.getValuesForLOBUpdateParameters(query);
-                    QueryLogger.logQueryParameters("bind", null, bindings, query instanceof InsertBatchQuery);
+                    QueryLogger.logQueryParameters(
+                            "bind",
+                            null,
+                            bindings,
+                            query instanceof InsertBatchQuery);
                 }
 
                 queryBuilder.bindParameters(statement, query);
@@ -137,7 +139,8 @@
             LOBBatchQueryWrapper selectQuery,
             List<DbAttribute> qualifierAttributes) throws SQLException, Exception {
 
-        List<DbAttribute> lobAttributes = selectQuery.getDbAttributesForUpdatedLOBColumns();
+        List<DbAttribute> lobAttributes = selectQuery
+                .getDbAttributesForUpdatedLOBColumns();
         if (lobAttributes.size() == 0) {
             return;
         }
@@ -245,9 +248,8 @@
      */
     private void writeBlob(Blob blob, byte[] value) {
 
-        Method getBinaryStreamMethod = OracleAdapter.getOutputStreamFromBlobMethod();
         try {
-            OutputStream out = (OutputStream) getBinaryStreamMethod.invoke(blob);
+            OutputStream out = blob.setBinaryStream(0);
             try {
                 out.write(value);
                 out.flush();
@@ -256,10 +258,6 @@
                 out.close();
             }
         }
-        catch (InvocationTargetException e) {
-            throw new CayenneRuntimeException("Error processing BLOB.", Util
-                    .unwindException(e));
-        }
         catch (Exception e) {
             throw new CayenneRuntimeException("Error processing BLOB.", Util
                     .unwindException(e));
@@ -271,11 +269,9 @@
      * driver utilities.
      */
     private void writeClob(Clob clob, char[] value) {
-        // obtain Writer and write CLOB
-        Method getWriterMethod = OracleAdapter.getWriterFromClobMethod();
         try {
 
-            Writer out = (Writer) getWriterMethod.invoke(clob);
+            Writer out = clob.setCharacterStream(0);
             try {
                 out.write(value);
                 out.flush();
@@ -285,12 +281,8 @@
             }
 
         }
-        catch (InvocationTargetException e) {
-            throw new CayenneRuntimeException("Error processing BLOB.", Util
-                    .unwindException(e));
-        }
         catch (Exception e) {
-            throw new CayenneRuntimeException("Error processing BLOB.", Util
+            throw new CayenneRuntimeException("Error processing CLOB.", Util
                     .unwindException(e));
         }
     }
@@ -300,11 +292,9 @@
      * driver utilities.
      */
     private void writeClob(Clob clob, String value) {
-        // obtain Writer and write CLOB
-        Method getWriterMethod = OracleAdapter.getWriterFromClobMethod();
         try {
 
-            Writer out = (Writer) getWriterMethod.invoke(clob);
+            Writer out = clob.setCharacterStream(0);
             try {
                 out.write(value);
                 out.flush();
@@ -312,14 +302,9 @@
             finally {
                 out.close();
             }
-
-        }
-        catch (InvocationTargetException e) {
-            throw new CayenneRuntimeException("Error processing BLOB.", Util
-                    .unwindException(e));
         }
         catch (Exception e) {
-            throw new CayenneRuntimeException("Error processing BLOB.", Util
+            throw new CayenneRuntimeException("Error processing CLOB.", Util
                     .unwindException(e));
         }
     }