OPENJPA-1248 Set null or empty_lob as appropriate when inserting a new streaming lob for update on Oracle. Also configured test to retain connection over the life of the tx and updated manual to document this requirement.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@834564 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2009-11-10 17:53:32 +00:00
parent 8f2ed40ac9
commit ab18db113b
3 changed files with 33 additions and 6 deletions

View File

@ -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());
}
}
}

View File

@ -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() {

View File

@ -1153,6 +1153,26 @@ Floats and doubles may lose precision when stored.
CLOB columns cannot be used in queries.
</para>
</listitem>
<listitem>
<para>
The use of LOBs with persistent attributes of a streaming data type (ex.
<literal>java.io.InputStream</literal> or <literal>java.io.Reader</literal>) 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 <literal>java.io.IOException</literal> with message <literal>Closed Connection
</literal> may result. The OpenJPA property <literal>openjpa.ConnectionRetainMode</literal>
can be used to control how OpenJPA uses datastore connections. See
<xref linkend="ref_guide_dbsetup_retain"/> for details.
<example id="dbsupport_oracle_retain_connection">
<title>
Property to retain connection over the lifetime of the entity manager
</title>
<programlisting>
openjpa.ConnectionRetainMode: always
</programlisting>
</example>
</para>
</listitem>
</itemizedlist>
</section>
</section>