[jboss-user] [EJB 3.0] - Type mapping problem with Decimal on DB2/400

lauerc do-not-reply at jboss.com
Thu Jul 5 10:02:48 EDT 2007


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!


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060830#4060830

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060830



More information about the jboss-user mailing list