cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r589096 - /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java
Date Sat, 27 Oct 2007 13:46:16 GMT
Author: aadamchik
Date: Sat Oct 27 06:46:15 2007
New Revision: 589096

URL: http://svn.apache.org/viewvc?rev=589096&view=rev
Log:
adding support for Serializable handling to the oracle adapter

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java?rev=589096&r1=589095&r2=589096&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryWrapper.java
Sat Oct 27 06:46:15 2007
@@ -20,10 +20,15 @@
 
 package org.apache.cayenne.access.trans;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.query.BatchQuery;
 
@@ -114,6 +119,25 @@
         if (value instanceof byte[]) {
             byte[] bytes = (byte[]) value;
             return bytes.length == 0 ? null : bytes;
+        }
+        else if (value instanceof Serializable) {
+            ByteArrayOutputStream bytes = new ByteArrayOutputStream() {
+
+                public synchronized byte[] toByteArray() {
+                    return buf;
+                }
+            };
+
+            try {
+                ObjectOutputStream out = new ObjectOutputStream(bytes);
+                out.writeObject(value);
+                out.close();
+            }
+            catch (IOException e) {
+                throw new CayenneRuntimeException("Error serializing object", e);
+            }
+            
+            return bytes.toByteArray();
         }
 
         return null;



Mime
View raw message