db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: Date and Timestamp problems
Date Sat, 26 Feb 2005 19:40:06 GMT

Hi Joerg,

"Joerg Friedrich" <friedj@users.sourceforge.net> schrieb am 25.02.2005

> Hi Thomas,
> you are right that MySQL works fine with the current implementation,
> it accepts the provided timestamp string even for date fields (YYYY-MM-DD
> HH:MM:SS). The default implementation for the date formatting function in
> the adapter is {ts ....}, which some database systems accept for
> but most likely not for DATE fields. In the case of Interbase/Firebird, a
> query on DATE fields thus crashes.
I was assuming in my first mail that we are talking about inserting Date
and Timestamp values and not about the adapters, so my mail might have been

> There is a huge variety of what database systems accept as date and
> timestamp notation. My suggestion was to clearly distinguish, as SQL does
> the meantime, between DATE and TIMESTAMP types. In the case of Interbase,
> can only choose to patch Torque to support TIMESTAMP correctly, or to
> support DATE correctly, using the adapter function. I cannot cover both
> (unless of course I drop the time portion of a timestamp).

>From a quick glance into the code, Torque is using one format for date,
time and timestamp data fields. So what you would need is that the adapter
would have the methods getDate(), getTime() and getTimestamp(). I do not
see a problem in this.

The remaining question is how the criteria object can determine which one
it should use. It could either use the type of the argument ((java.sql.Date
and java.util.date), java.sql.Time or java.sql.timestamp) to determine
which method should be used, or it could look at the db maps and find out
which type the column is. I know that the first option would work; I am not
sure about the second option, have to think about it.

To make sure this is not forgotten, can you create a Scarab account and
open up an issue on this ? (http://issues.apache.org/scarab/issues/)

> The Oracle problem goes even a little deeper, since there are x versions
> Oracle JDBC drivers around which behave quite different regarding the way
> they interpret DATE and TIMESTAMP. In the long run I think the safe way
> go would be to have DATE really just use the date portion, and TIMESTAMP
> date and time portion. Most database vendors that I have watched move
> way. Even MySQL which was quite tolerant in this matter has with their
> latest release begun to distinguish more clearly between these two SQL
> types.
> On another note, I have extended the DBFactory class and written a new
> adapter for the Firebird/Jaybird database based on the 3.1.1 release. The
> current support for Interbase/Firebird is a little bit outdated. Are you
> interested in these files? If yes how should I submit them?

I would be interested in the adapters. Can you please create a new issue in
Torque>source and upload your changes there ? Please put in an apache 2.0
Licence in your files (copy any header from a Torque java source file.)



> Joerg
> -----Urspr√ľngliche Nachricht-----
> Von: Thomas Fischer [mailto:fischer@seitenbau.net]
> Gesendet: Freitag, 25. Februar 2005 15:44
> An: Apache Torque Developers List
> Betreff: RE: Date and Timestamp problems
> Hi Joerg,
> the only problem I am aware of is that Oracle Timestamps are not
> at the moment (i.e. date is used instead, and rounded to day accuracy).
> There is already an open issue in scarab about this
> (http://issues.apache.org/scarab/issues/id/TRQS263), which will be
> in the next release. You can change the mapping from Date to timestamps
> the oracle db.props file if you want to fix it yourself. If you do that,
> timestamps have at least millisecond accuracy.
> I have heard that mysql timestamps are ok (at least millisec accurancy),
> correct me if I'm wrong.
> I do not know anything about interbase and MSSQL. Can you enlighten me
> ?
>      Thomas
> Jörg Friedrich <joerg.friedrich@emron.de> schrieb am 25.02.2005 14:59:20:
> > Hi,
> >
> > we have had problems with date fields and timestamps when working with
> > different database systems. In our application we support for example
> > Interbase, MySQL, Oracle and MS SQLServer. The adapter class of Torque
> > as far as I could see has a method for the date format. However, there
> > is no method for the timestamp format. This format may differ for
> > different database systems/JDBC drivers. Would it be possible to add a
> > suitable
> method
> > in a future release?
> >
> > Thanks.
> >
> > Joerg
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org

To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message