1

I'm porting an application written for Sybase and Hibernate 3.6.4 to start using Oracle 11g. As I understand people were able to get Hibernate working with Oracle 11g using Oracle10gDialect. I'm using that but for one of the columns which is mapped java.lang.Double I'm having issues.

When I create the table with the column as BINARY_DOUBLE, hibernate complains saying:

Caused by: org.hibernate.HibernateException: Wrong column type in TEST_SCHEMA.TEST_TABLE for column PERCENTAGE. Found: binary_double, expected: double precision

and when I define the column as DOUBLE PRCEISION, it complains saying:

Caused by: org.hibernate.HibernateException: Wrong column type in TEST_SCHEMA.TEST_TABLE for column PERCENTAGE. Found: float, expected: double precision

Looking at the docs both of these errors make sense because there's no Double data type in Oracle. But looking at the Dialect code, I'm not sure why I'm seeing the second error.

Class org.hibernate.dialect.Oracle8iDialect has this method which has "double precision" mapped to Types.DOUBLE

protected void registerNumericTypeMappings() {
    registerColumnType( Types.BIT, "number(1,0)" );
    registerColumnType( Types.BIGINT, "number(19,0)" );
    registerColumnType( Types.SMALLINT, "number(5,0)" );
    registerColumnType( Types.TINYINT, "number(3,0)" );
    registerColumnType( Types.INTEGER, "number(10,0)" );

    registerColumnType( Types.FLOAT, "float" );
    registerColumnType( Types.DOUBLE, "double precision" );
    registerColumnType( Types.NUMERIC, "number($p,$s)" );
    registerColumnType( Types.DECIMAL, "number($p,$s)" );
}

So, I'm not sure why DOUBLE PRECISION is not working for me. Any pointers on what I'm doing wrong here. I'm sure those who have tested Oracle11gDialect would have used Double in their code.

Thanks, K.

KumarM
  • 1,669
  • 1
  • 18
  • 26

1 Answers1

1

When you define a column with DOUBLE PRECISION Oracle automatically converts it to FLOAT which could be verified with the SQL statement DESCRIBE <TABLE>;. By default, there is no mapping of Types.DOUBLE to float.

See Hibernate: Found: float, expected: double precision for adding this mapping via extending the class Oracle10gDialect.

Community
  • 1
  • 1
Sebastian S.
  • 1,545
  • 6
  • 24
  • 41