From 9f5e44d05f978455408e2739aee236658085bd31 Mon Sep 17 00:00:00 2001 From: Michael Dick Date: Thu, 14 Oct 2010 01:08:41 +0000 Subject: [PATCH] OPENJPA-1699: Streaming LOB support for DB2 > Submitted by Heath Thomann, based on Fay's patch for trunk git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@1022338 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/sql/DB2Dictionary.java | 33 +++++++++++++++++-- .../jdbc/meta/strats/AbstractLobTest.java | 4 ++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java index 49d737685..2fb37e8fa 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java @@ -19,6 +19,8 @@ package org.apache.openjpa.jdbc.sql; import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.Reader; import java.lang.reflect.Method; import java.sql.Blob; import java.sql.Connection; @@ -29,12 +31,11 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import java.util.Arrays; -import java.util.Set; import java.util.StringTokenizer; import org.apache.openjpa.jdbc.identifier.DBIdentifier; -import org.apache.openjpa.jdbc.identifier.QualifiedDBIdentifier; import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; +import org.apache.openjpa.jdbc.kernel.JDBCStore; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; import org.apache.openjpa.jdbc.kernel.exps.Lit; import org.apache.openjpa.jdbc.kernel.exps.Param; @@ -939,6 +940,34 @@ public class DB2Dictionary String nullSafe(String s) { return s == null ? "" : s; } + + public void insertBlobForStreamingLoad(Row row, Column col, + JDBCStore store, Object ob, Select sel) throws SQLException { + if (ob != null) { + row.setBinaryStream(col, (InputStream)ob, -1); + } else { + row.setNull(col); + } + } + + public void insertClobForStreamingLoad(Row row, Column col, Object ob) + throws SQLException { + if (ob != null) { + row.setCharacterStream(col, (Reader)ob, -1); + } else { + row.setNull(col); + } + } + + public void updateBlob(Select sel, JDBCStore store, InputStream is) + throws SQLException { + //NO-OP + } + + public void updateClob(Select sel, JDBCStore store, Reader reader) + throws SQLException { + //NO-OP + } @Override public boolean isFatalException(int subtype, SQLException ex) { diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java index aa743e543..2bf2bbbec 100644 --- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/strats/AbstractLobTest.java @@ -30,6 +30,7 @@ import javax.persistence.Query; import org.apache.commons.lang.StringUtils; import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.datacache.DataCachePCData; +import org.apache.openjpa.jdbc.sql.DB2Dictionary; import org.apache.openjpa.jdbc.sql.DBDictionary; import org.apache.openjpa.jdbc.sql.MySQLDictionary; import org.apache.openjpa.jdbc.sql.OracleDictionary; @@ -50,7 +51,8 @@ public abstract class AbstractLobTest extends SingleEMFTestCase { protected List> supportedDatabases = new ArrayList> - (Arrays.asList(MySQLDictionary.class, OracleDictionary.class, SQLServerDictionary.class)); + (Arrays.asList(MySQLDictionary.class, OracleDictionary.class, SQLServerDictionary.class, + DB2Dictionary.class)); public void setUp() throws Exception { setSupportedDatabases(supportedDatabases.toArray(new Class[] {}));