UtilDateType materializeObject for non-date type

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Mar 11 2004 - 12:06:20 EST

  • Next message: Andrus Adamchik: "Re: UtilDateType materializeObject for non-date type"

    Andrus,

    I noticed that your UtilDateType.materializeObject uses

                default :
                    val = rs.getObject(index);
                    break;

    instead of (which I copied from convertToJdbcObject above)

                throw new IllegalArgumentException(
                    "Only date/time types can be used for '" + getClassName() +
    "'.");

    Since a non-date/time type is going to throw a less-informative
    ClassCastException anyway, why not point out the exact problem? Otherwise,
    when Oracle or someone switches to a non-conforming class (like in the
    Oracle 8 to 9 upgrade), it's going to be less obvious what went wrong.

    For example, here's the errors I got when I upgraded DATEs to TIMESTAMP
    fields for Cayenne and WebObjects.

    java.lang.ClassCastException
            at
    org.objectstyle.cayenne.access.types.UtilDateType.materializeObject(UtilDateType.java:133)

    versus something like

    [com.webobjects.jdbcadaptor.JDBCAdaptorException]
    oracle.sql.TIMESTAM..122a1 of type oracle.sql.TIMESTAMP is not a valid Date
    type. You must use java.sql.Timestamp, java.sql.Date, or java.sql.Time



    This archive was generated by hypermail 2.0.0 : Thu Mar 11 2004 - 12:05:15 EST