Hibernate Books

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Mapping ORACLE TIMESTAMP(9) field to java.util.Date
PostPosted: Mon Jul 16, 2012 8:27 pm 
Newbie

Joined: Mon Jul 16, 2012 7:37 pm
Posts: 1
Having issues mapping a ORACLE TIMESTAMP(9) field to java.sql.Timestamp or java.util.Date in Java
Versions:-
ojdbc 11.2.0.1.0
hibernate-annotations 3.3.1.GA
ejb3-persistence 1.0.1.GA

Trying to map UPDATE_TIMESTAMP_9 TIMESTAMP(9) NULL ==> @Column(name = "UPDATE_TIMESTAMP_9") private Date updateTimestamp_9;

Get Exception
org.hibernate.HibernateException: Wrong column type in EMPLOYEE.EMPLOYEE for column UPDATE_TIMESTAMP_9. Found: timestamp, expected: date

The code returns 'false' at the following line in Table.java
Code:
final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase()
                  .startsWith( columnInfo.getTypeName().toLowerCase() )
                  || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );


1. col.getSqlType( dialect, mapping ) for Date or Timestamp field is date.
columnInfo.getTypeName() is timestamp so the first part of the if query will not match

2. col.getSqlTypeCode( mapping ) returns 93 (which is code for Types.TIMESTAMP). However, columnInfo.getTypeCode() returns 1111. So even the secondpart of the query doesnt match.

Problem is that while populating ColumnMetadata rs.getInt("DATA_TYPE") for field UPDATE_TIMESTAMP_9 returns a 1111 which is code for Types.OTHER. Please note that if i use TIMESTAMP(6) field in oracle columnInfo.getTypeCode() correctly returns 93 and the code successfully inserts a record. Problem is only with TIMESTAMP(9).

Crossposted http://stackoverflow.com/questions/11530722/mapping-oracle-timestamp9-field-to-java-util-date


Top
 Profile  
 
 Post subject: Re: Mapping ORACLE TIMESTAMP(9) field to java.util.Date
PostPosted: Tue Jul 17, 2012 8:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
As I posted on StackOverflow, just disable schema validation. Thats where this exception arises.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.