Oracle TIMESTAMP getObject(index) returns oracle.sql.TIMESTAMP

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Mar 01 2004 - 23:32:14 EST

  • Next message: Andrus Adamchik: "Re: Oracle TIMESTAMP getObject(index) returns oracle.sql.TIMESTAMP"

    I've been sick with the flu for a week which is why I've been mercifully
    quiet recently. :-)

    However, the week before, I finally confirmed (with assistance from
    DataDirect's JDBC driver support department) that Oracle's DATE type cannot
    be compared for equality to a java.sql.Timestamp. Worse, the latest Oracle
    9i driver embedded in Oracle Application Server now returns all DATE fields
    with the hours/minutes/seconds/fractions zeroed out. Ie, Oracle is
    secretly removing the ability to store and retrieve datetime info in DATE
    fields [At least I've not seen this documented anywhere.]

    Not only that, but SQL Server's JDBC driver for TIMESTAMP now behaves the
    same way, according to DataDirect. (It might have been Sybase -- I wasn't
    really paying attention at that point since I only use OpenBase and Oracle.)

    So, I caved in and converted my Oracle database fields from DATE to
    TIMESTAMP earlier today.

    Which now brings the next bit of fun.

    Oracle's 9i database drivers return oracle.sql.TIMESTAMP objects when called
    with ResultSet.getObject().
    And of course, this object is not compatible with anything in the java.sql
    package or with java.util.Date.

    Cayenne fails with a ClassCastException on materialization.

    I did some testing, and ResultSet.getTimestamp and .getDate do return the
    proper objects with the Oracle Driver.

    Is there a reason that Cayenne doesn't use getTimestamp() instead of
    getObject() for date objects?

    This looks like it could be fixed for all drivers for all time by changing
    .getObject(index) to .getTimestamp(index) for all occurrences in
    org.objectstyle.cayenne.access.types.UtilDateType.

    -Mike

    Rhetorical question -- Am I the only programmer on the planet using datetime
    fields in Oracle 9i? How in the world has anyone else done anything useful
    this stuff under Oracle 9i short of writing raw JDBC?



    This archive was generated by hypermail 2.0.0 : Mon Mar 01 2004 - 23:32:02 EST