openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1337605 - in /openjpa/branches/2.1.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/
Date Sat, 12 May 2012 18:41:16 GMT
Author: hthomann
Date: Sat May 12 18:41:15 2012
New Revision: 1337605

URL: http://svn.apache.org/viewvc?rev=1337605&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.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
    openjpa/branches/2.1.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
    openjpa/branches/2.1.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1337605&r1=1337604&r2=1337605&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Sat May 12 18:41:15 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;
@@ -288,6 +289,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;
@@ -935,6 +937,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.1.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=1337605&r1=1337604&r2=1337605&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Sat May 12 18:41:15 2012
@@ -223,3 +223,7 @@ 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.    

Modified: openjpa/branches/2.1.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=1337605&r1=1337604&r2=1337605&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
(original)
+++ openjpa/branches/2.1.x/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
Sat May 12 18:41:15 2012
@@ -1494,7 +1494,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.1.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1337605&r1=1337604&r2=1337605&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml (original)
+++ openjpa/branches/2.1.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Sat May 12
18:41:15 2012
@@ -3408,6 +3408,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>



Mime
View raw message