您的位置:首页 > 其它

项目经验:Hibernate 映射配置文件precision与scale的用法

2014-07-10 09:03 387 查看
Oracle使用标准、可变长度的内部格式来存储数字,这个内部格式精度可以高达38位。

NUMBER数据类型可以有两个限定符,如:

column NUMBER ( precision, scale)

precision表示数字中的有效位。如果没有指定precision的话,Oracle将使用38作为精度。

scale表示数字小数点右边的位数,scale默认设置为0.  如果把scale设成负数,Oracle将把该数字取舍到小数点左边的指定位数。

eg:<column name="id" precision="15" scale="2" />

 

 

 

例子:TDsrcLake.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.richway.baseinfomana.domain.TDsrcLake" table="T_DSRC_LAKE" schema="HWSZY">
<id name="lkCd" type="string">
<column name="LK_CD" length="15" />
<generator class="assigned" />
</id>
<property name="adCd" type="string">
<column name="ad_cd" />
</property>
<property name="lkTp" type="string">
<column name="LK_TP" length="1" />
</property>
<property name="bsnm" type="string">
<column name="BSNM" length="30" />
</property>
<property name="hnnm" type="string">
<column name="HNNM" length="30" />
</property>
<property name="avW" type="double">
<column name="AV_W" precision="10" scale="3" />
</property>
<property name="croTp" type="string">
<column name="CRO_TP" length="1" />
</property>
<property name="ts" type="java.util.Date">
<column name="TS" not-null="true" />
</property>
<property name="nt" type="string">
<column name="NT" length="256" />
</property>
<property name="adNm" formula="(select a.ad_nm from WR_AD_B a where a.ad_cd=ad_cd)"/>
</class>
</hibernate-mapping>


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: