Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Mike Kienenberger
Don't know if it'll apply in your situation, but make sure you've got the most recent oracle drivers. In the past, I saw the behavior change depending on what driver I was using. I also switched all of my DATE fields to TIMESTAMPs in the end. On Wed, Jan 28, 2009 at 12:31 PM, Alessio Giovanni

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Joe Baldwin
Is it possible that the problem is with the JDBC adapter version? I googled Oracle Date and found this brain-numbing essay on Oracle-JDBC- DATE-Date-Timestamp and the the version complications as well. http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#08_01 (I a

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Alessio Giovanni Baroni
Nothing, returns an exception ("getTimestamp is not valid for getT4CNumber ."). If I use "TO_CHAR", there is another problem, because when I do get(...) from DataObject, Cayenne execute a query, not equal as the query in ctxt.performQuery(Bar.class, "SELEC"); Cayenne not save the TO_CHA

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Andrus Adamchik
java.sql.Timestamp extends java.util.Date, so it is ok. (and in any event doublecheck that the column in a table for the Bar entity is mapped as TIMESTAMP). Andrus On Jan 28, 2009, at 5:34 PM, Alessio Giovanni Baroni wrote: But if I have SQLTemplate(Bar.class, .), and in class Bar I set

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Alessio Giovanni Baroni
But if I have SQLTemplate(Bar.class, .), and in class Bar I set the field Foo as Date, isn't an error cast it to java.lang.Timestamp?? Thanks. 2009/1/28 Andrus Adamchik > My (admittedly novice) solution was to map it via Modeler to a TIMESTAMP. >> > > > This is actually a correct solution

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Andrus Adamchik
My (admittedly novice) solution was to map it via Modeler to a TIMESTAMP. This is actually a correct solution. Only if I am not mistaken it doesn't work 100% on 2.0.x (IIRC it works for SelectQuery, but not SQLTemplate). In 3.0 it should work with SQLTemplate as well. Andrus On Jan 28

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Andrus Adamchik
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.Timestam

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Joe Baldwin
Andrus, I looked up the Oracle Date definition and it does in fact keep time info in the database. My (admittedly novice) solution was to map it via Modeler to a TIMESTAMP. Does this reveal the same problem with the Oracle adapter as mapping it via Modeler-DATE? Joe On Jan 28, 2009, a

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Michael Gentry
"SELECT #result('FOO' 'java.sql.Timestamp') FROM BAR" On Wed, Jan 28, 2009 at 10:05 AM, Alessio Giovanni Baroni < alessiogiovanni.bar...@gmail.com> wrote: > A simple example? > > Thanks. > > > 2009/1/28 Andrus Adamchik > > > I guess that's how Oracle driver returns the metadata for the DATE col

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Alessio Giovanni Baroni
A simple example? Thanks. 2009/1/28 Andrus Adamchik > 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, > >

Re: Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Andrus Adamchik
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 wr

Problems with Date in Cayenne 2.0.4

2009-01-28 Thread Alessio Giovanni Baroni
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