db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Dietrick <robert.dietr...@nokia.com>
Subject Torque + Oracle 9i + DATE columns losing time SOLUTION
Date Thu, 04 Aug 2005 17:30:47 GMT
Just thought I would document the solution I found to a problem which 
seems to be fairly prevalent.  It took a full day of searching mailing 
lists, hacking the Village classes, and scouring the Oracle support 
message boards to finally find this simple solution:


We recently upgraded from Oracle 8.1.7 to Oracle 9i.  With the new 
version of the Oracle 9i JDBC drivers Oracle changed the way they report 
the column type meta data for date columns.  This causes the village 
library to think DATE columns are SQL DATE types rather than DATETIME 
and truncate the time portion of dates before inserting into these columns.

The often quoted solution is to modify your XML database schema to 
define your DATE columns instead as TIMESTAMP and regenerate your DDL. 
However, this doesn't help you if you've already got a deployed schema 
with data in it.  It would be a failry tedious process for a DBA to 
modify the column types of populated tables.

It turns out there is a system property you can set which forces the 
Oracle JDBC drivers into version 8 compatibility mode with respect to 
reporting of date types in meta-data.  Just pass this to your Java VM 
with "-Doracle.jdbc.V8Compatible=true", and, walla!, Torque now persists 
the time portion of your date columns once again.

The only remaining question now is: why on earth does Torque query the 
database meta data before inserting when the OR mapping provides all the 
information the system needs about the database?

Robert Dietrick

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

View raw message