do you mean that standard JDBC escapes do not work for them? If they do work
then you simply need to remove the getDateString() methods from adapters so
that they use default impl.
--
fedor.
----
Broad-mindedness, n.:
The result of flattening high-mindedness out.
> -----Original Message-----
> From: Bill Schneider [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 08, 2002 11:00 AM
> To: [EMAIL PROTECTED]
> Subject: [PATCH] DBOracle, DBPostgres
>
>
> This patches the Oracle and Postgres adapters for Torque, which were
> breaking when using dates in criteria, for example
>
> criteria.add(DATE_COLUMN, new java.util.Date(), Criteria.LESS_EQUAL);
>
> Index: src/java/org/apache/torque/adapter/DBOracle.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/tor
> que/adapter/DBOracle.java,v
> retrieving revision 1.8
> diff -u -r1.8 DBOracle.java
> --- src/java/org/apache/torque/adapter/DBOracle.java 22 Aug
> 2001 20:12:08 -0000 1.8
> +++ src/java/org/apache/torque/adapter/DBOracle.java 8 Mar
> 2002 18:25:13 -0000
> @@ -55,6 +55,7 @@
> */
>
> import java.util.Date;
> +import java.text.SimpleDateFormat;
> import java.lang.reflect.Method;
>
> import java.sql.Connection;
> @@ -74,6 +75,9 @@
> public class DBOracle
> extends DB
> {
> + private static final SimpleDateFormat DATE_FORMATTER =
> + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> +
> /**
> * Empty constructor.
> */
> @@ -222,7 +226,7 @@
> */
> public String getDateString(String dateString)
> {
> - return "TO_DATE('" + dateString + "', 'yyyy-mm-dd
> hh24:mi:ss..' )";
> + return "TO_DATE('" + dateString + "', 'yyyy-mm-dd hh24:mi:ss' )";
> }
>
> /**
> @@ -233,6 +237,7 @@
> */
> public String getDateString(Date date)
> {
> - return "TO_DATE('" + date.toString() + "', 'yyyy-mm-dd
> hh24:mi:ss..' )";
> + return "TO_DATE('" + DATE_FORMATTER.format(date) +
> + "', 'yyyy-mm-dd hh24:mi:ss' )";
> }
> }
> Index: src/java/org/apache/torque/adapter/DBPostgres.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/tor
> que/adapter/DBPostgres.java,v
> retrieving revision 1.5
> diff -u -r1.5 DBPostgres.java
> --- src/java/org/apache/torque/adapter/DBPostgres.java
> 21 Feb 2002 16:55:19 -0000 1.5
> +++ src/java/org/apache/torque/adapter/DBPostgres.java
> 8 Mar 2002 18:25:13 -0000
> @@ -56,6 +56,8 @@
>
> import java.sql.Connection;
> import java.sql.SQLException;
> +import java.util.Date;
> +import java.text.SimpleDateFormat;
>
> /**
> * This is used to connect to PostgresQL databases.
> @@ -68,6 +70,9 @@
> public class DBPostgres
> extends DB
> {
> + private static final SimpleDateFormat DATE_FORMATTER =
> + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> +
> /**
> * Empty constructor.
> */
> @@ -202,5 +207,17 @@
> public int getLimitStyle()
> {
> return DB.LIMIT_STYLE_POSTGRES;
> + }
> +
> + /**
> + * This method is used to format any date string.
> + * Database can use different default date formats.
> + *
> + * @return The proper date formatted String.
> + */
> + public String getDateString(Date date)
> + {
> + return "TO_TIMESTAMP('" + DATE_FORMATTER.format(date) +
> +
> "', 'yyyy-mm-dd hh24:mi:ss' )";
> }
> }
>
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>