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