Yes, java.util.Date is Cayenne default mapping for the date types, so
if there are no other hints in the query, this is what Cayenne will use.
> The type of "fromDate" is java.util.Date - I'm not even able to select
> that type in the modeller
Actually you can - you should type "java.util.Date" (without the
quotes) in that dropdown.
There is also a brute-force way to specify the type you want via
#result directive in a SQLTemplate:
http://cwiki.apache.org/CAYDOC/scripting-sqltemplate.html
But I would simply change the mappings to use util.Date instead of
sql.Timestamp.
Andrus
On Sep 21, 2006, at 6:16 PM, Chris Poulsen wrote:
> Hi guys,
>
> I've been having some trouble with <subj>, I hope someone have an
> reasonable explaination. :)
>
> I've generated both my classes and db schema using the v1.2 modeller.
>
> The problem is that when I try to access a field in the generated
> class
> I get a class cast exception in the getter below:
>
> public void setFromDate(java.sql.Timestamp fromDate) {
> writeProperty("fromDate", fromDate);
> }
> public java.sql.Timestamp getFromDate() {
> return (java.sql.Timestamp)readProperty("fromDate");
> }
>
> The type of "fromDate" is java.util.Date - I'm not even able to select
> that type in the modeller and the types are set to timestamps
> everywhere in the modeller/db.
>
> I can get my code to behave as I expect if i return a:
> new Timestamp( ( (Date)readProperty("fromDate) ).getTime() )
> in the getter instead. My query is basically a select * from <table>
> (though I've tried specifying the columns explicitly etc.)
>
> Is this a bug, stupidity on my part or perhaps a jdbc driver bug
> (tried
> 2 differet versions)?
>
> btw I'm using PostgreSQL v8.0.8, jdbc-driver v8.0-317-jdbc3 if that
> matters.
>
> --
> Regards Chris
>
This archive was generated by hypermail 2.0.0 : Thu Sep 21 2006 - 18:42:07 EDT