Re: Problems with Date in Cayenne 2.0.4

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jan 28 2009 - 10:15:13 EST

  • Next message: Andrus Adamchik: "Re: Problems with Date in Cayenne 2.0.4"

    Didn't realize it doesn't support JDBC type in the #result. I think
    you can still force it by specifying "java.sql.Timestamp" as the Java
    class:

    String sql = "SELECT"
        + " #result('ARTIST_ID' 'int'),"
        + " #result('ARTIST_NAME' 'String'),"
        + " #result('DATE_OF_BIRTH' 'java.sql.Timestamp')"
        + " FROM ARTIST";
    SQLTemplate select = new SQLTemplate(Artist.class, sql);

    Andrus

    On Jan 28, 2009, at 5:05 PM, Alessio Giovanni Baroni wrote:

    > A simple example?
    >
    > Thanks.
    >
    >
    > 2009/1/28 Andrus Adamchik <andru..bjectstyle.org>
    >
    >> I guess that's how Oracle driver returns the metadata for the DATE
    >> column
    >> in the ResultSet. The workaround is to use #result() directive in
    >> the SQL:
    >>
    >> http://cayenne.apache.org/doc20/scripting-sqltemplate.html
    >>
    >> Hope this helps,
    >>
    >> Andrus
    >>
    >>
    >> On Jan 28, 2009, at 4:48 PM, Alessio Giovanni Baroni wrote:
    >>
    >> Hi to all,
    >>> I have the following code:
    >>>
    >>> .............
    >>> query = new SQLTemplate("SELECT FOO FROM BAR");
    >>> results = ctxt.performQuery(Bar.class, query);
    >>> for(int i = 0; i < results.size() - 1; ++i)
    >>> {
    >>> Bar f = (Bar)results.get(i);
    >>> ...... (f.getFoo());
    >>> ....................
    >>> }
    >>>
    >>> In the Oracle DB the field FOO is a DATE and I map it to
    >>> java.util.Date.
    >>> When I do .getFoo(), the date that I have is without the
    >>> hours/minutes/seconds.
    >>> Why? How do I resolve it?
    >>>
    >>> Thanks.
    >>>
    >>
    >>



    This archive was generated by hypermail 2.0.0 : Wed Jan 28 2009 - 10:15:44 EST