Mantis - Resin
Viewing Issue Advanced Details
871 major always 01-17-06 10:06 02-02-06 10:09
koreth  
ferg  
normal  
closed 3.0.17  
fixed  
none    
none 3.0.18  
0000871: Wrong datatype used when EJB container creates an instance with a null LONGVARBINARY column
I have an Oracle table with a LONG RAW column that's allowed to be null. My resin.ejb has the following definition for the field:

            <cmp-field>
                <field-name>methodParametersByteArrayField</field-name>
                <sql-column>methodparameters</sql-column>
                <abstract-sql-type>LONGVARBINARY</abstract-sql-type>
                <sql-type>LONG RAW</sql-type>
            </cmp-field>

But the following code gets generated in the __Amber.java file:

    if (__caucho_super_get_methodParametersByteArrayField() == null)
      pstmt.setNull(index++, java.sql.Types.DECIMAL);
    else
      pstmt.setBytes(index++, __caucho_super_get_methodParametersByteArrayField());

When I try to create a bean instance where the field in question is null, the JDBC call throws an exception with a message from Oracle, "expected BINARY but found NUMBER". Clearly the setNull() call shouldn't be using java.sql.Types.DECIMAL as its data type.

Notes
(0000722)
koreth   
01-17-06 11:06   
Patch:

--- modules/resin/src/com/caucho/amber/type/ByteArrayType.java.orig 2006-01-17 10:51:51.266923262 -0800
+++ modules/resin/src/com/caucho/amber/type/ByteArrayType.java 2006-01-17 10:51:55.022416994 -0800
@@ -92,7 +92,7 @@
     throws IOException
   {
     out.println("if (" + value + " == null)");
- out.println(" " + pstmt + ".setNull(" + index + "++, java.sql.Types.DECIMAL);");
+ out.println(" " + pstmt + ".setNull(" + index + "++, java.sql.Types.BINARY);");
     out.println("else");
     out.println(" " + pstmt + ".setBytes(" + index + "++, " + value + ");");
   }
(0000842)
ferg   
02-02-06 10:09   
ejb/06jn