Dear Wiki user, You have subscribed to a wiki page or wiki category on "Db-torque Wiki" for change notification.
The following page has been changed by dkreutz: http://wiki.apache.org/db-torque/OracleFAQ ------------------------------------------------------------------------------ See also http://db.apache.org/torque/runtime/oracle-howto.html - == What should i know when using Oracle's data type DATE and TIMESTAMP == + == What should i know when using Oracle's datatype DATE and TIMESTAMP == - Oracles data type DATE support date and time with an accuracy up to seconds, which is fine for many applications. + Oracle datatype DATE supports date and time with an accuracy up to seconds, which is fine for many applications. - Since Version 9i Oracle introduced additional data type TIMESTAMP that supports additional accuracy within fractions of seconds. + Since Version 9i Oracle introduced additional datatype TIMESTAMP that supports additional accuracy within fractions of seconds. + So far so good, but: + - So far so good, but unfortunately the village library used by Torque to read/write data from/into databases truncates dates by setting hours, minutes and seconds all to zero. So although oracle has a better precision in its Date datatype, you can not use the better precision in Torque. + 1. The village library used by Torque to read/write data from/into databases truncates dates by setting hours, minutes and seconds all to zero. So although oracle has a better precision in its DATE datatype, you can not use the better precision in Torque. + + 2. In Version 9.2 of the JDBC-driver Oracle changed the mapping of datatype DATE from java.sql.Timestamp (prior 9.2) to java.sql.Date (since 9.2) leading to a loss of time information. + + See also http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#08_01 === So what if I need exact date and time? === - 1. When generating your Torque-classes specify all columns as type="TIMESTAMP" in the schema.xml for Torque-Generator, regardless if they are data type DATE or TIMESTAMP in your Oracle-schema. + 1. When generating your Torque-classes specify all columns as type="TIMESTAMP" in the schema.xml for Torque-Generator, regardless if they are datatype DATE or TIMESTAMP in your Oracle-schema. - 1. In your Oracle schema use data type TIMESTAMP for all columns where you need full date and time. This is recommended when creating a new database schema. You can easily convert DATE-columns to TIMESTAMP as Oracle casts these data types automatically (UPDATE mytable set newTimestampColumn=oldDateColumn). For existing database (especially in production environment) this may not be feasible: + 1. In your Oracle schema use datatype TIMESTAMP for all columns where you need full date and time. This is recommended when creating a new database schema. You can easily convert DATE-columns to TIMESTAMP as Oracle casts these datatype automatically (UPDATE mytable set newTimestampColumn=oldDateColumn). For existing database (especially in production environment) this may not be feasible: - 1. You may still use Oracles data type DATE. If you want correct time portion of the data you must specify Java-VM parameter "-Doracle.jdbc.V8Compatible=true" that causes the JDBC-driver to use old behaviour of JDBC-driver prior to Oracle 9i (returning full date and time for data type DATE) + 1. You may still use Oracles datatype DATE. If you want correct time portion of the data you must specify Java-VM parameter "-Doracle.jdbc.V8Compatible=true" that causes the JDBC-driver to use old behaviour of JDBC-driver prior to Oracle 9i (returning full date and time for data type DATE) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
