You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by ht...@apache.org on 2012/05/14 21:06:35 UTC
svn commit: r1338346 - in /openjpa/branches/2.2.x:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/
openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/
openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/
openjpa-project/src/doc/manual/
Author: hthomann
Date: Mon May 14 19:06:35 2012
New Revision: 1338346
URL: http://svn.apache.org/viewvc?rev=1338346&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/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
openjpa/branches/2.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1338346&r1=1338345&r2=1338346&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Mon May 14 19:06:35 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 = false;//OPENJPA-2067
public int maxEmbeddedBlobSize = -1;
public int maxEmbeddedClobSize = -1;
public int inClauseLimit = -1;
@@ -968,6 +970,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.warn(_loc.get("jdbc4-setbinarystream-unsupported"));
+ }
+ }
+
stmnt.setBinaryStream(idx, val, length);
}
Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=1338346&r1=1338345&r2=1338346&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties (original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties Mon May 14 19:06:35 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/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=1338346&r1=1338345&r2=1338346&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java (original)
+++ openjpa/branches/2.2.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java Mon May 14 19:06:35 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/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1338346&r1=1338345&r2=1338346&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml (original)
+++ openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Mon May 14 19:06:35 2012
@@ -3424,6 +3424,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>.
+By default 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 false.
+ </para>
+ </listitem>
<listitem id="DBDictionary.UseNativeSequenceCache">
<para>
<indexterm>