0 Replies Latest reply on Jul 5, 2007 10:02 AM by Christian Lauer

    Type mapping problem with Decimal on DB2/400

    Christian Lauer Newbie

      I'm trying to manage a table on an DB2/400 with a EJB3 entity bean but Hibernate failes to correctly map the database data type to a data type in the entity bean.

      The column type is defined as follows:

       PREIS DECIMAL(12,5)
      

      When I define the getter like
       @Column(name = "PREIS", precision = 13, scale = 5)
       public BigDecimal getPreis() {...
      

      I get the following error:
      javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: PREIS, expected: numeric(13,5)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
      ...
      

      I've tried to fix the problem by changing the annotation like:
       @Column(name = "PREIS", columnDefinition = "DECIMAL(13,5)")
      

      The result of this attempt was:
      javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: PREIS, expected: DECIMAL(13,5)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
      ...
      


      I've also tried to combie the annotation attributes like this:
       @Column(name = "PREIS", columnDefinition = "DECIMAL(13,5)", precision = 13, scale = 5, nullable = true)
      

      but the result stays the same.

      Any suggestions deeply appreciated!