java - Hibernate如何Mapping Decimal
ringa_lee
ringa_lee 2017-04-17 11:23:19
0
1
575

在我的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_lee
ringa_lee

ringa_lee

reply all(1)
大家讲道理

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template