[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2261) Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields

Diego Pires Plentz (JIRA) noreply at atlassian.com
Sat Sep 29 16:47:25 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28253 ] 

Diego Pires Plentz commented on HHH-2261:
-----------------------------------------

"In MySQL, NUMERIC is implemented as DECIMAL."
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

> Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields
> ------------------------------------------------------------------------------------
>
>                 Key: HHH-2261
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2261
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.1
>            Reporter: Christian Sprajc
>            Assignee: Diego Pires Plentz
>             Fix For: 3.2.6
>
>
> Hello,
> We got a Problem when using the following setup:
> 1) JBoss 4.0.4A with Hibernate 3.2.0 / mySQl 4.x AND 5.x
> 2) Set hibernate.hbm2ddl.auto=validate
> 3) Using a usertype which uses the SQL type: Types.NUMERIC
> When deploying our application I got the following error:
> 12:43:21,985 INFO  [TableMetadata] columns: [paymenttype, amount, oid, remarks, currency, ae_date]
> 12:43:21,985 WARN  [ServiceController] Problem starting service persistence.units:jar=com.riege.pogo_0.1.4.jar,unitName=PogoEntityManager
> org.hibernate.HibernateException: Wrong column type: amount, expected: numeric(19,2)
>         at org.hibernate.mapping.Table.validateColumns(Table.java:251)
>         at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1002)
> The Problem is:
> 1) When hibernate creates (e.g. hibernate.hbm2ddl.auto=update) through the columns in the mySQL database it creates it as "numeric(x,y)" field.
> 2) mySQL always converts "numeric(x,y)" to "decimal(x,y)". The metadata returns "decimal(x,y)"
> 3) When deploying with "hibernate.hbm2ddl.auto=validate" to error above is thrown. The problem is that hibernate expects a "numeric(x,y)" type but mysql returns a "decimal(x,y)"
> A workaround I'm now using is a fixed mySQL dialect which correctly handles Types.DECIMAL / "decimal(x,y)":
> public class FixedMySQLDialect extends org.hibernate.dialect.MySQLDialect {
>     public FixedMySQLDialect() {
>         super();
>         registerColumnType(Types.NUMERIC, "decimal(19, $l)");
>         registerColumnType(Types.DECIMAL, "decimal(19, $l)");
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list