I have a problem with the mapping of Oracle Float double precision datatype to Java Double datatype. The hibernate schema validator seems to fail when the Java Double datatype is used.
org.hibernate.HibernateException: Wrong column type in DB.TABLE for column amount. Found: float, expected: double precision
The only way to avoid this is to disable schema validation and hope the schema is in sync with the app about to run. It must be fixed before it goes out to production.
App's evironment:
- Grails 1.2.1
- Hibernate-core 3.3.1.GA
- Oracle 10g
Unless you define a column type as double precision
in DDL file, Oracle will convert it to float
column type. So you need to register double as float column type in dialect class.
public class Oracle10gDialectExtended extends Oracle10gDialect {
public Oracle10gDialectExtended() {
super();
registerColumnType(Types.DOUBLE, "float");
}
}
Finally register Oracle10gDialectExtended
in Hibernate/JPA configuration as hibernate.dialect
.
Need more info. The table is Double? I'm not familiar with Oracle, but is that a floating point type? What java.sql.Types
type does it translate to? You can see the java.sql.Types
to database type mapping in the dialect class for your database. In this case it is org.hibernate.dialect.Oracle10gDialect
(which extends 9i and 8i). Looks like you have
registerColumnType( Types.DOUBLE, "double precision" );
So, the table needs to be defined as double precision
, and the java class needs to be defined as something that will map to Types.Double
, usually double
.
From the error message, it looks like your table is defined as float
which would use this mapping
registerColumnType( Types.FLOAT, "float" );
for which the expected java type would be something that maps to Types.FLOAT
, usually float
; a single precision value.
The easiest thing to do is either change your table or java class to match. Alternately, you can specify a user type that would map a single precision value to a double precision value; I can't think of why you would really want to do that, but maybe if you didn't have control over both the class and the table, which is quite rare, I would think.
hth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With