6 Replies Latest reply on Nov 8, 2007 6:53 AM by Dean Pullen

    How to map a java double type in hibernate to oracle NUMBER?

    Richard Yang Apprentice

      Sorry I have to repost this question as I forgot to include a title for the previous one.

      I have struggled for days getting a java.lang.Double filed mapped to oracle NUMBER type with precision 4 and scale 1.
      I tried this:

      <column name="ValidityAgreePercent" sql-type="NUMBER(4,1)" />

      and


      <column name="ValidityAgreePercent" sql-type="NUMBER(4,1)" />

      and

      <column name="ValidityAgreePercent" sql-type="NUMBER precision="4" and scale="1 " />

      And over two dozen combinations.
      None worked.

      Does this validation have anything to do with jdbc driver?
      My dialect is Oracle9Dialect.
      We use jboss 4.0.3SP1 (hibernate jars come with this jboss release).

      This is what I got:

      org.hibernate.HibernateException: Wrong column type: ValidityAdjacentPercent, expected: NUMBER(4,1)
      at org.hibernate.mapping.Table.validateColumns(Table.java:205)
      at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:956)
      at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
      at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:299)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145)
      at com.pearson.resource.adapter.jmx.jboss.hibernate.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:220)
      at com.pearson.resource.adapter.jmx.jboss.hibernate.HibernateSessionFactory.startService(HibernateSessionFactory.java:100)
      at com.pearson.epen.service.SessionFactoryDeployer.addSessionFactoryForDatasource(SessionFactoryDeployer.java:91)
      at com.pearson.epen.service.DataSourceListener$DeployerThread.deploySessionFactory(DataSourceListener.java:416)
      at com.pearson.epen.service.DataSourceListener$DeployerThread.run(DataSourceListener.java:393)


      I even tried big_decimal. It does not work either.
      The same mapping works for sql-server where we have decimal in the database as a type.

      Please help. I don't see any example.