-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: OracleDialect and timestamp
PostPosted: Wed May 19, 2004 4:46 pm 
Newbie

Joined: Tue Sep 09, 2003 6:19 pm
Posts: 9
From the Manual:

5.2.2. Basic value types

date, time, timestamp

Type mappings from java.util.Date and its subclasses to SQL types DATE, TIME and TIMESTAMP (or equivalent).

Looking at the src, OracleDialect uses date for each of these. Why do time and timestamp use date instead of their respective SQL types?

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 6:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Because Oracle 8i (for which the OracleDialect is targetted) makes no distinction between any of those. It always stores these as full date time. Not sure if this changed in 9i or not.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 11:04 pm 
Newbie

Joined: Tue Sep 09, 2003 6:19 pm
Posts: 9
The date datatype is precise to the second where the timestamp datatype is precise to the millisecond.

FYI, I've been able to sub-class the OracleDialect class and change it to timestamp and everything appears to work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 7:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
The date datatype is precise to the second where the timestamp datatype is precise to the millisecond.

Thats untrue. java.sql.Timestamp is supposed to be precise to the nanosecond (which Oracle DATEs do not support). java.sql.Date is supposed to be have all of its time fields set to zero.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 20, 2004 12:40 pm 
Newbie

Joined: Tue Sep 09, 2003 6:19 pm
Posts: 9
I was refering to Oracle date and timestamp not Java.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 15, 2004 1:25 am 
Newbie

Joined: Tue Jul 13, 2004 8:29 am
Posts: 1
I stumbled into the same problems in Version 2.1.2. In Version 2.1.4 the mapping still is the same:

Code in constructor of Oracle9Dialect
Code:
      registerColumnType( Types.DATE, "DATE" );
      registerColumnType( Types.TIME, "DATE" );
      registerColumnType( Types.TIMESTAMP, "DATE" );



From the OracleDocuments at [url]http://download-west.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/sql_elements2.htm#54201
[/url]
DATE : Valid date range from January 1, 4712 BC to December 31, 9999 AD.

TIMESTAMP (fractional_seconds_precision) : Year, month, and day values of date, as well as hour, minute, and second values of time, where fractional_seconds_precision is the number of digits in the fractional part of the SECOND datetime field. Accepted values of fractional_seconds_precision are 0 to 9. The default is 6.

Thus oracle offers nanosecond precision.

I fixed it by subclassing with a constructor:

Code:
public MyDialect() {
  super() ;
  registerColumnType( Types.DATE, "TIMESTAMP(3)" );
}

as I just needed the java.util.Date equivalent.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.