diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java index 87586d91d..9b5a18c86 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java @@ -1161,9 +1161,12 @@ public class OracleDictionary public void insertClobForStreamingLoad(Row row, Column col, Object ob) throws SQLException { - if (ob == null) + if (ob == null) { col.setType(Types.OTHER); - row.setNull(col); + row.setNull(col); + } else { + row.setClob(col, getEmptyClob()); + } } public int getBatchUpdateCount(PreparedStatement ps) throws SQLException { @@ -1202,8 +1205,11 @@ public class OracleDictionary @Override public void insertBlobForStreamingLoad(Row row, Column col, JDBCStore store, Object ob, Select sel) throws SQLException { - if (ob == null) + if (ob == null) { col.setType(Types.OTHER); - row.setNull(col); - } + row.setNull(col); + } else { + row.setBlob(col, getEmptyBlob()); + } + } } 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 01cab7f45..b25f0582e 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 @@ -49,7 +49,8 @@ public abstract class AbstractLobTest extends SingleEMFTestCase { public void setUp() throws Exception { super.setUp(getLobEntityClass(), CLEAR_TABLES, "openjpa.DataCache", "true", - "openjpa.RemoteCommitProvider", "sjvm"); + "openjpa.RemoteCommitProvider", "sjvm", + "openjpa.ConnectionRetainMode", "transaction"); } public boolean isDatabaseSupported() { diff --git a/openjpa-project/src/doc/manual/supported_databases.xml b/openjpa-project/src/doc/manual/supported_databases.xml index 565e9d7ee..e19a49984 100644 --- a/openjpa-project/src/doc/manual/supported_databases.xml +++ b/openjpa-project/src/doc/manual/supported_databases.xml @@ -1153,6 +1153,26 @@ Floats and doubles may lose precision when stored. CLOB columns cannot be used in queries. + + +The use of LOBs with persistent attributes of a streaming data type (ex. +java.io.InputStream or java.io.Reader) may +require the same connection to be used over the life of the transaction or +entity manager. If the same connection is not used for persistent operations +a java.io.IOException with message Closed Connection + may result. The OpenJPA property openjpa.ConnectionRetainMode +can be used to control how OpenJPA uses datastore connections. See + for details. + + + Property to retain connection over the lifetime of the entity manager + + +openjpa.ConnectionRetainMode: always + + + +