Hi Gurus :-)
it works. Here is a kind of a resum� to be added to the castor
documentation, faq or just to apear in this mail list to help by
similar issues:
Problem: how to map an object of type java.util.Date to the mysql DATETIME?
Solution: the column in the db table has the type DATETIME. The
configuration file must look like this:
<field name="loginDateTime" type="java.util.Date">
<sql name="loginDT" type="timestamp"/>
</field>
Note that the sql type is TIMESTAMP und not DATETIME.
ex.:
Session ses = new Session();
Date d = new Date((new GregorianCalendar(1990,0,17,10,04,23)).getTime());
ses.setDate(d);
mapping the object ses to the databse will add the value [1990-01-17
10:04:23] into the
loginDT filed.
et voil�.
Aziz
On 6/14/05, Werner Guttmann <[EMAIL PROTECTED]> wrote:
> Thanks, Ralf. That's exactly what I had in mind when asking Aziz why he
> thinks that DATETIME is not supported.
>
> Werner
>
> wg> -----Original Message-----
> wg> From: Ralf Joachim [mailto:[EMAIL PROTECTED]
> wg> Sent: Tuesday, June 14, 2005 1:42 PM
> wg> To: [email protected]
> wg> Subject: Re: [castor-user] [JDO] support for the mysql type datetime
> wg>
> wg>
> wg> Hi Aziz,
> wg>
> wg> if you use:
> wg>
> wg> <field name="creationTime" type="java.util.Date">
> wg> <sql name="ctime" type="timestamp" />
> wg> </field>
> wg>
> wg> in mapping.xml and create the ctime column with type
> wg> DATETIME then it
> wg> works without patching castor.
> wg>
> wg> Regards
> wg> Ralf
> wg>
> wg>
> wg>
> wg> Aziz Hammadi schrieb:
> wg> > Hi all!
> wg> > I am just wondering while the mysql type DATETIME has
> wg> not yet been
> wg> > implemented. The MySQL Connector/J supports allready this type by
> wg> > using java.sql.Timestamp to model it. I tried to hack the
> wg> castor code
> wg> > (SQLTypes.java) to map datetime to
> wg> java.sql.Timestamp.class. I added
> wg> > the following entry
> wg> > new TypeInfo( java.sql.Types.TIMESTAMP, "datetime",
> wg> =3D20
> wg> > java.sql.Timestamp.class),
> wg> > to the =5FtypeInfos array.
> wg> >
> wg> > Well this little change produced the value "1989-01-24
> wg> 00:00:00" in my
> wg> > table. I guess it needs more modifications to handle the 00:00:00
> wg> > part. What do you think=3F is this a correct concept=3F
> wg> >
> wg> > reference:
> http://www.issociate.de/board/post/18070/JConnector=5F3.0=5Fand=5FDAT=
> > ETIME.html
> >
> >
> > Cheers
> > Aziz
> >
> > -------------------------------------------------
> > If you wish to unsubscribe from this list, please
> > send an empty message to the following address:
> >
> > [EMAIL PROTECTED]
> > -------------------------------------------------
>
> --
>
> Syscon Ingenieurb�ro f�r
> Me�- und Datentechnik GmbH
> Ralf Joachim
> Raiffeisenstra�e 11
> D-72127 Kusterdingen
> Germany
>
> Tel. +49 7071 3690 52
> Mobil: +49 173 9630135
> Fax +49 7071 3690 98
>
> Email: [EMAIL PROTECTED]
> Web: www.syscon-world.de
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>
--
Aziz Hammadi Lamrani
email: [EMAIL PROTECTED]
url: http://user.et-cip.rub.de/hammadi/
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------