Author: hthomann
Date: Tue May 15 00:42:09 2012
New Revision: 1338494
URL: http://svn.apache.org/viewvc?rev=1338494&view=rev
Log:
OPENJPA-2067: Added code, gated by the new DBDictionary.useJDBC4SetBinaryStream
prop, to use a JDBC 4.0 version of setBinaryStream.
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1338494&r1=1338493&r2=1338494&view=diff
==============================================================================
---
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Tue May 15 00:42:09 2012
@@ -28,6 +28,7 @@ import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
+import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Array;
@@ -291,6 +292,7 @@ public class DBDictionary
public boolean useGetObjectForBlobs = false;
public boolean useGetStringForClobs = false;
public boolean useSetStringForClobs = false;
+ public boolean useJDBC4SetBinaryStream = true;//OPENJPA-2067
public int maxEmbeddedBlobSize = -1;
public int maxEmbeddedClobSize = -1;
public int inClauseLimit = -1;
@@ -969,6 +971,19 @@ public class DBDictionary
public void setBinaryStream(PreparedStatement stmnt, int idx,
InputStream val, int length, Column col)
throws SQLException {
+
+ //OPENJPA-2067: If the user has set the 'useJDBC4SetBinaryStream'
property
+ //then lets use the JDBC 4.0 version of the setBinaryStream method.
+ if (useJDBC4SetBinaryStream) {
+ if (isJDBC4){
+ stmnt.setBinaryStream(idx, val);
+ return;
+ }
+ else {
+
log.trace(_loc.get("jdbc4-setbinarystream-unsupported"));
+ }
+ }
+
stmnt.setBinaryStream(idx, val, length);
}
Modified:
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=1338494&r1=1338493&r2=1338494&view=diff
==============================================================================
---
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
(original)
+++
openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Tue May 15 00:42:09 2012
@@ -223,6 +223,10 @@ sequencesql-override: Going to override
invalid-locking-mode: Invalid locking mode for SolidDB: "{0}"
oracle-set-clob-warning: Setting the supportsSetClob property on the
OracleDictionary no longer has an \
effect. The functionality provided by the supportsSetClob property is
now enabled, by default.
+jdbc4-setbinarystream-unsupported: The JRE or JDBC level in use does not
support the \
+ JDBC 4.0 version of the "java.sql.PreparedStatement.setBinaryStream"
method which is \
+ necessary when the property
"openjpa.jdbc.DBDictionary=useJDBC4SetBinaryStream" is \
+ set to true. A prior version of this method will be used.
sequence-cache-warning: Setting the useNativeSequenceCache property on the
DBDictionary no longer has an \
effect. Code has been added to allow, by default, the functionality
provided in previous releases \
via the useNativeSequenceCache property.
Modified:
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=1338494&r1=1338493&r2=1338494&view=diff
==============================================================================
---
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
(original)
+++
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
Tue May 15 00:42:09 2012
@@ -1429,7 +1429,13 @@ public class LoggingConnectionDecorator
setLogParameter(i1, "InputStream", is);
super.setBinaryStream(i1, is, i2);
}
-
+
+ public void setBinaryStream(int i1, InputStream is)
+ throws SQLException {
+ setLogParameter(i1, "InputStream", is);
+ super.setBinaryStream(i1, is);
+ }
+
public void clearParameters() throws SQLException {
clearLogParameters(false);
super.clearParameters();
Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1338494&r1=1338493&r2=1338494&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
(original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Tue May
15 00:42:09 2012
@@ -3451,6 +3451,27 @@ ResultSet.getString</methodname> will be
<methodname>ResultSet.getCharacterStream</methodname>.
</para>
</listitem>
+
+ <listitem id="DBDictionary.UseJDBC4SetBinaryStream">
+ <para>
+ <indexterm>
+ <primary>
+ JDBC
+ </primary>
+ <secondary>
+ UseJDBC4SetBinaryStream
+ </secondary>
+ </indexterm>
+<literal>UseJDBC4SetBinaryStream</literal>: When true, an attempt will be made
to obtain
+a JDBC 4.0 version of
<methodname>PreparedStatement.setBinaryStream</methodname>.
+When false, a <methodname>setBinaryStream</methodname> is used which takes the
length of the
+stream. OpenJPA uses a -1 for the length since OpenJPA doesn't know the
length of the stream.
+A few JDBC drivers check the length and throw an exception when the length is
less than zero.
+When this property is set to true, and an applicable JDK and JDBC 4.0 driver
is available, a
+version of <methodname>setBinaryStream</methodname> will be used which does
not take a length.
+The default value of this property is true.
+ </para>
+ </listitem>
<listitem id="DBDictionary.UseNativeSequenceCache">
<para>
<indexterm>