Hi Craig & Mike, I believe the reflection mentioned was introduced in order to compile with JDK 1.3 (JDBC 2) and use JDK 1.4 (JDBC 3) methods on Blob/Clob and has nothing to do with JDK 5/6 (i.e. JDBC 3/4).
I haven't tried to build with JDK 6 and run with JDK 5 yet. However, why do you think it won't run? We are using only JDK 5 and below methods. If this proves to be a problem then the problem is a little broader - for example we use Blob methods in DBDictionary.updateBlob method (streaming BLOB functionality). Cheers, Milosz > Hi Craig, > > Thanks for the explanation. The tests always build from scratch, currently. > I could certainly add tests that build with one and run with the other (or > both) though. > > -mike > > On Tue, Jun 16, 2009 at 1:16 PM, Craig L Russell wrote: > > > Hi Mike, > > > > The code will work if you build from source and run on the same platform > > you compiled on. > > > > But a binary distribution won't work (IIRC) if you run on a different > > platform than what the distribution was built with. > > > > Do your tests compile on 6 and run on both 5 and 6? > > > > Thanks, > > > > Craig > > > > > > On Jun 16, 2009, at 11:04 AM, Michael Dick wrote: > > > > I don't have a Java 6 configuration for MySQL, but I do run Sun JDK 5&6 > >> and > >> IBM SDK 5&6 with Derby every night. These builds are passing now. > >> > >> -mike > >> > >> On Tue, Jun 16, 2009 at 12:52 PM, Craig L Russell > >wrote: > >> > >> Hi, > >>> > >>> Has this change been tested with JDK 5 and JDK 6? I thought the reason > >>> for > >>> the reflection stuff was the incompatibility between JDBC3 and JDBC4 so > >>> you > >>> couldn't write the same code for both platforms. > >>> > >>> I might (probably?) have missed the discussion on how to resolve > >>> http://issues.apache.org/jira/browse/OPENJPA-5 which is central to this > >>> issue. > >>> > >>> Craig > >>> > >>> > >>> On Jun 7, 2009, at 1:13 AM, [email protected] wrote: > >>> > >>> Author: mtylenda > >>> > >>>> Date: Sun Jun 7 08:13:41 2009 > >>>> New Revision: 782338 > >>>> > >>>> URL: http://svn.apache.org/viewvc?rev=782338&view=rev > >>>> Log: > >>>> OPENJPA-1122: Remove JDBC 3 related reflection from DBDictionary > >>>> > >>>> Modified: > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java > >>>> > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java > >>>> > >>>> Modified: > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java > >>>> URL: > >>>> > >>>> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java?rev=782338&r1=782337&r2=782338&view=diff > >>>> > >>>> > >>>> ============================================================================== > >>>> --- > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java > >>>> (original) > >>>> +++ > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedBlobFieldStrategy.java > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -18,6 +18,7 @@ > >>>> */ > >>>> package org.apache.openjpa.jdbc.meta.strats; > >>>> > >>>> +import java.sql.Blob; > >>>> import java.sql.ResultSet; > >>>> import java.sql.SQLException; > >>>> > >>>> @@ -89,7 +90,7 @@ > >>>> DBDictionary dict) > >>>> throws SQLException { > >>>> byte[] b = (byte[]) sm.setImplData(field.getIndex(), null); > >>>> - Object blob = rs.getBlob(1); > >>>> + Blob blob = rs.getBlob(1); > >>>> dict.putBytes(blob, b); > >>>> } > >>>> > >>>> > >>>> Modified: > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java > >>>> URL: > >>>> > >>>> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java?rev=782338&r1=782337&r2=782338&view=diff > >>>> > >>>> > >>>> ============================================================================== > >>>> --- > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java > >>>> (original) > >>>> +++ > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedByteArrayFieldStrategy.java > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -19,6 +19,7 @@ > >>>> package org.apache.openjpa.jdbc.meta.strats; > >>>> > >>>> import java.lang.reflect.Array; > >>>> +import java.sql.Blob; > >>>> import java.sql.ResultSet; > >>>> import java.sql.SQLException; > >>>> > >>>> @@ -72,7 +73,7 @@ > >>>> protected void putData(OpenJPAStateManager sm, ResultSet rs, > >>>> DBDictionary dict) > >>>> throws SQLException { > >>>> - Object blob = rs.getBlob(1); > >>>> + Blob blob = rs.getBlob(1); > >>>> dict.putBytes(blob, > >>>> PrimitiveWrapperArrays.toByteArray(sm.fetchObject > >>>> (field.getIndex()))); > >>>> } > >>>> @@ -80,7 +81,7 @@ > >>>> protected Object load(Column col, Result res, Joins joins) > >>>> throws SQLException { > >>>> return PrimitiveWrapperArrays.toObjectValue(field, > >>>> - (byte[]) res.getBytes(col, joins)); > >>>> + res.getBytes(col, joins)); > >>>> } > >>>> > >>>> public void map(boolean adapt) { > >>>> > >>>> Modified: > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java > >>>> URL: > >>>> > >>>> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java?rev=782338&r1=782337&r2=782338&view=diff > >>>> > >>>> > >>>> ============================================================================== > >>>> --- > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java > >>>> (original) > >>>> +++ > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedCharArrayFieldStrategy.java > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -23,6 +23,7 @@ > >>>> import java.io.IOException; > >>>> import java.io.Reader; > >>>> import java.lang.reflect.Array; > >>>> +import java.sql.Clob; > >>>> import java.sql.ResultSet; > >>>> import java.sql.SQLException; > >>>> > >>>> @@ -77,7 +78,7 @@ > >>>> protected void putData(OpenJPAStateManager sm, ResultSet rs, > >>>> DBDictionary dict) > >>>> throws SQLException { > >>>> - Object clob = rs.getClob(1); > >>>> + Clob clob = rs.getClob(1); > >>>> dict.putChars(clob, PrimitiveWrapperArrays. > >>>> toCharArray(sm.fetchObject(field.getIndex()))); > >>>> } > >>>> > >>>> Modified: > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java > >>>> URL: > >>>> > >>>> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java?rev=782338&r1=782337&r2=782338&view=diff > >>>> > >>>> > >>>> ============================================================================== > >>>> --- > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java > >>>> (original) > >>>> +++ > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/MaxEmbeddedClobFieldStrategy.java > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -18,6 +18,7 @@ > >>>> */ > >>>> package org.apache.openjpa.jdbc.meta.strats; > >>>> > >>>> +import java.sql.Clob; > >>>> import java.sql.ResultSet; > >>>> import java.sql.SQLException; > >>>> > >>>> @@ -66,7 +67,7 @@ > >>>> protected void putData(OpenJPAStateManager sm, ResultSet rs, > >>>> DBDictionary dict) > >>>> throws SQLException { > >>>> - Object clob = rs.getClob(1); > >>>> + Clob clob = rs.getClob(1); > >>>> dict.putString(clob, sm.fetchString(field.getIndex())); > >>>> } > >>>> > >>>> > >>>> 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=782338&r1=782337&r2=782338&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 > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -28,8 +28,6 @@ > >>>> import java.io.Reader; > >>>> import java.io.StringReader; > >>>> import java.io.Writer; > >>>> -import java.lang.reflect.InvocationTargetException; > >>>> -import java.lang.reflect.Method; > >>>> import java.math.BigDecimal; > >>>> import java.math.BigInteger; > >>>> import java.sql.Array; > >>>> @@ -394,11 +392,6 @@ > >>>> // first time it happens we can warn the user > >>>> private Set _precisionWarnedTypes = null; > >>>> > >>>> - // cache lob methods > >>>> - private Method _setBytes = null; > >>>> - private Method _setString = null; > >>>> - private Method _setCharStream = null; > >>>> - > >>>> // batchLimit value: > >>>> // -1 = unlimited > >>>> // 0 = no batch > >>>> @@ -1421,55 +1414,27 @@ > >>>> /** > >>>> * Invoke the JDK 1.4 setBytes method on the given BLOB > >>>> object. > >>>> */ > >>>> - public void putBytes(Object blob, byte[] data) > >>>> + public void putBytes(Blob blob, byte[] data) > >>>> throws SQLException { > >>>> - if (_setBytes == null) { > >>>> - try { > >>>> - _setBytes = blob.getClass().getMethod("setBytes", > >>>> - new Class[]{ long.class, byte[].class }); > >>>> - } catch (Exception e) { > >>>> - throw new StoreException(e); > >>>> - } > >>>> - } > >>>> - invokePutLobMethod(_setBytes, blob, > >>>> - new Object[]{ Numbers.valueOf(1L), data }); > >>>> + blob.setBytes(1L, data); > >>>> } > >>>> > >>>> /** > >>>> * Invoke the JDK 1.4 setString method on the given CLOB > >>>> * object. > >>>> */ > >>>> - public void putString(Object clob, String data) > >>>> + public void putString(Clob clob, String data) > >>>> throws SQLException { > >>>> - if (_setString == null) { > >>>> - try { > >>>> - _setString = clob.getClass().getMethod("setString", > >>>> - new Class[]{ long.class, String.class }); > >>>> - } catch (Exception e) { > >>>> - throw new StoreException(e); > >>>> - } > >>>> - } > >>>> - invokePutLobMethod(_setString, clob, > >>>> - new Object[]{ Numbers.valueOf(1L), data }); > >>>> + clob.setString(1L, data); > >>>> } > >>>> > >>>> /** > >>>> * Invoke the JDK 1.4 setCharacterStream method on the > >>>> given > >>>> * CLOB object. > >>>> */ > >>>> - public void putChars(Object clob, char[] data) > >>>> + public void putChars(Clob clob, char[] data) > >>>> throws SQLException { > >>>> - if (_setCharStream == null) { > >>>> - try { > >>>> - _setCharStream = clob.getClass().getMethod > >>>> - ("setCharacterStream", new Class[]{ long.class }); > >>>> - } catch (Exception e) { > >>>> - throw new StoreException(e); > >>>> - } > >>>> - } > >>>> - > >>>> - Writer writer = (Writer) invokePutLobMethod(_setCharStream, > >>>> clob, > >>>> - new Object[]{ Numbers.valueOf(1L) }); > >>>> + Writer writer = clob.setCharacterStream(1L); > >>>> try { > >>>> writer.write(data); > >>>> writer.flush(); > >>>> @@ -1479,24 +1444,6 @@ > >>>> } > >>>> > >>>> /** > >>>> - * Invoke the given LOB method on the given target with the given > >>>> data. > >>>> - */ > >>>> - private static Object invokePutLobMethod(Method method, Object > >>>> target, > >>>> - Object[] args) > >>>> - throws SQLException { > >>>> - try { > >>>> - return method.invoke(target, args); > >>>> - } catch (InvocationTargetException ite) { > >>>> - Throwable t = ite.getTargetException(); > >>>> - if (t instanceof SQLException) > >>>> - throw(SQLException) t; > >>>> - throw new StoreException(t); > >>>> - } catch (Exception e) { > >>>> - throw new StoreException(e); > >>>> - } > >>>> - } > >>>> - > >>>> - /** > >>>> * Warn that a particular value could not be stored precisely. > >>>> * After the first warning for a particular type, messages > >>>> * will be turned into trace messages. > >>>> > >>>> Modified: > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java > >>>> URL: > >>>> > >>>> http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?rev=782338&r1=782337&r2=782338&view=diff > >>>> > >>>> > >>>> ============================================================================== > >>>> --- > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java > >>>> (original) > >>>> +++ > >>>> > >>>> openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java > >>>> Sun Jun 7 08:13:41 2009 > >>>> @@ -949,7 +949,7 @@ > >>>> * vendor-specific class; for example Weblogic wraps oracle thin driver > >>>> * lobs in its own interfaces with the same methods. > >>>> */ > >>>> - public void putBytes(Object blob, byte[] data) > >>>> + public void putBytes(Blob blob, byte[] data) > >>>> throws SQLException { > >>>> if (blob == null) > >>>> return; > >>>> @@ -970,7 +970,7 @@ > >>>> * vendor-specific class; for example Weblogic wraps oracle thin driver > >>>> * lobs in its own interfaces with the same methods. > >>>> */ > >>>> - public void putString(Object clob, String data) > >>>> + public void putString(Clob clob, String data) > >>>> throws SQLException { > >>>> if (_putString == null) { > >>>> try { > >>>> @@ -989,7 +989,7 @@ > >>>> * vendor-specific class; for example Weblogic wraps oracle thin driver > >>>> * lobs in its own interfaces with the same methods. > >>>> */ > >>>> - public void putChars(Object clob, char[] data) > >>>> + public void putChars(Clob clob, char[] data) > >>>> throws SQLException { > >>>> if (_putChars == null) { > >>>> try { > >>>> > >>>> > >>>> > >>>> Craig L Russell > >>> Architect, Sun Java Enterprise System http://db.apache.org/jdo > >>> 408 276-5638 mailto:[email protected] > >>> P.S. A good JDO? O, Gasp! > >>> > >>> > >>> > > Craig L Russell > > Architect, Sun Java Enterprise System http://db.apache.org/jdo > > 408 276-5638 mailto:[email protected] > > P.S. A good JDO? O, Gasp! > > > > >
