Re: Cayenne, Oracle and Date-based queries...

From: Mike Kienenberger (mkienen..laska.net)
Date: Tue Oct 12 2004 - 14:47:14 EDT

  • Next message: Marcia Corprew: "NullPointerException in call to DataContext.createDataContext()"

    Andrus Adamchik <andru..bjectstyle.org> wrote:
    > To my knowledge JDBC driver takes a good care of the date conversions if a
    > corresonding column is mapped as the right JDBC date/time type. Could you
    > try mapping DbAttribute "patients.birthdt" as DATE and not TIMESTAMP or
    > TIME?

    My suspicion is that Julien is trying to compare a DATE or TIMESTAMP field
    to a java String type rather than a Date type.

    Julian, make sure you're comparing to a Date value rather than assuming that
    the JDBC driver will correctly translate a String type to a Date type.
    I've had no problems comparing DATE and TIMESTAMP Oracle 9i types to
    java.util.Dates with Cayenne.

    Using the java.text.SimpleDateFormat, you can simulate any behavior for
    which you would have needed to use TO_DATE().

    > > Hello everybody,
    > > I recently switched to Cayenne for our medical query application on a
    > > Oracle 9i DB, so my Cayenne's knowledge is still limited. So far,
    > > everything is working great and smoothly except when it comes date-based
    > > queries.
    > >
    > > For example :
    > >
    > > // doesn't work (i.e. no rows returned)
    > > SELECT t0.patientsname FROM imagedev.patients t0 WHERE (t0.birthdt =
    > > '1953-05-31')
    > >
    > > // works (x rows returned)
    > > SELECT t0.patientsname FROM imagedev.patients t0 WHERE (t0.birthdt =
    > > TO_DATE('1953-05-31','YYYY-MM-DD'))
    > >
    > >
    > > Is there a way to add some oracle SQL functions such as "TO_DATE()" in
    > > an Qualifier or should I use SQLTemplate instead since it is db
    > > vendor-dependant functionality ? Does Cayenne can be aware of the
    > > NLS_PARAMETERS and use them ?
    > >
    > > Thanks :-)
    > > Julien
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Oct 12 2004 - 14:46:09 EDT