Jon has fixed Village so that the conversion from Timestamp to util.Date
only results in the loss of precision for 10^-4 seconds.  I am
interested in hearing the actual precision supported by some of the
databases in use.  Does Postgres, MySQL, Oracle, etc. have precision
higher than milliseconds?

John McNally

[EMAIL PROTECTED] wrote:
> 
> Sorry for the late: I send you the patch for the mapping of
> TIMESTAMP type into java.sql.Timestamp (and not java.util.Date).
> It is also necessary to introduce in the templates of torque the following
> line:
> 
> import java.sql.Timestamp;
> 
> I think that the usage of java.util.Date produce a losing of information
> that I
> experimented in my project.
> I solved my problems by mapping TIMESTAMP into java.sql.Timestamp.
> 
> Michela
> 
> PATCH FOR TypeMap.java
> 
> --- TypeMap.java.old    Thu Feb 22 16:03:58 2001
> +++ TypeMap.java        Thu Feb 22 16:13:06 2001
> @@ -66,7 +66,9 @@
>  //
>  //import java.sql.Date;
>  //import java.sql.Time;
> -//import java.sql.Timestamp;
> +
> +import java.sql.Timestamp;
> +import java.lang.System;
> 
>  /**
>   * A class that maps JDBC types to their corresponding
> @@ -98,7 +100,7 @@
>   * LONGVARBINARY | byte[]               | ?
>   * DATE          | java.sql.Date        | java.util.Date
>   * TIME          | java.sql.Time        | java.util.Date
> - * TIMESTAMP     | java.sql.Timestamp   | java.util.Date
> + * TIMESTAMP     | java.sql.Timestamp   | java.sql.Timestamp
>   *
>   * -------------------------------------------------------
>   * A couple variations have been introduced to cover cases
> @@ -160,7 +162,7 @@
>      public static final String BLOB_OBJECT_TYPE = "new Object()"; //?
>      public static final String DATE_OBJECT_TYPE = "new Date()";
>      public static final String TIME_OBJECT_TYPE = "new Date()";
> -    public static final String TIMESTAMP_OBJECT_TYPE = "new Date()";
> +    public static final String TIMESTAMP_OBJECT_TYPE = "new
> Timestamp(System.currentTimeMillis())";
>      public static final String BOOLEANCHAR_OBJECT_TYPE = "new String()";
>      public static final String BOOLEANINT_OBJECT_TYPE = "new Integer(0)";
> 
> @@ -184,7 +186,7 @@
>      public static final String BLOB_NATIVE_TYPE = "byte[]";
>      public static final String DATE_NATIVE_TYPE = "Date";
>      public static final String TIME_NATIVE_TYPE = "Date";
> -    public static final String TIMESTAMP_NATIVE_TYPE = "Date";
> +    public static final String TIMESTAMP_NATIVE_TYPE = "Timestamp";
>      public static final String BOOLEANCHAR_NATIVE_TYPE = "boolean";
>      public static final String BOOLEANINT_NATIVE_TYPE = "boolean";
> 
> @@ -208,7 +210,7 @@
>      public static final String BLOB_VILLAGE_METHOD = "asBytes()";
>      public static final String DATE_VILLAGE_METHOD = "asDate()";
>      public static final String TIME_VILLAGE_METHOD = "asDate()";
> -    public static final String TIMESTAMP_VILLAGE_METHOD = "asDate()";
> +    public static final String TIMESTAMP_VILLAGE_METHOD = "asTimestamp()";
>      public static final String BOOLEANCHAR_VILLAGE_METHOD = "asString()";
>      public static final String BOOLEANINT_VILLAGE_METHOD = "asInt()";
> 
> @@ -230,7 +232,7 @@
>      public static final String LONGVARBINARY_PP_METHOD =
> "getBytes(ppKey)";
>      public static final String DATE_PP_METHOD = "getDate(ppKey)";
>      public static final String TIME_PP_METHOD = "getDate(ppKey)";
> -    public static final String TIMESTAMP_PP_METHOD = "getDate(ppKey)";
> +    public static final String TIMESTAMP_PP_METHOD =
> "getTimestamp(ppKey)";
>      public static final String BOOLEANCHAR_PP_METHOD =
> "getBoolean(ppKey)";
>      public static final String BOOLEANINT_PP_METHOD = "getBoolean(ppKey)";
> 
> PATCH FOR BasePeer.java
> 
> --- BasePeer.java.old   Thu Feb 22 16:18:14 2001
> +++ BasePeer.java       Thu Feb 22 16:20:16 2001
> @@ -806,6 +806,9 @@
>                  else if ( obj instanceof java.util.Date)
>                      rec.setValue( colMap.getColumnName(),
>                                    (java.util.Date)obj );
> +                else if ( obj instanceof java.sql.Timestamp)
> +                    rec.setValue( colMap.getColumnName(),
> +                                  (java.sql.Timestamp)obj );
>                  else if ( obj instanceof Float)
>                      rec.setValue( colMap.getColumnName(),
>                                    criteria.getFloat(key) );
> 
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to