search

Home  >  Q&A  >  body text

java - Hibernate如何Mapping Decimal

在我的Mysql数据库里,定义了一个字段,其类型是Decimal(6.3), 那我使用hibernate进行ORM的时候,在hbm.xml文件中,要如何设置呢?

<property name="something“ type="big_decimal" precision="6" scale="3" column="someColumn"/>

但是提示错误,错误信息如下:

Wrong column type: someColumn, expected: numeric(6,3)

我是用的mysql是5.6, Hibernate是4.2.8-Final

ringa_leeringa_lee2821 days ago599

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:25:19

    Use the following mapping relationship:

    <property name='something' type='float'>
      <column name="someColumn" sql-type='decimal(6.3)'/>
    </property>
    

    For details, please see: http://docs.jboss.org/hibernate/orm/3.3/reference/zh-CN/html/toolsetguide.html Section 20.1.1

    reply
    0
  • Cancelreply