hibernate配置保存2位小数
类:
public class Account {private Integer accountId; //账户idprivate BigDecimal accountMoney; //账户总金额private BigDecimal accountLockMoney;//锁定金额private Date accountCreateDate; //创建时间配置文件:<?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"><hibernate-mapping package="cn.anycall.bean"> <class name="Account" table="tuan_account"> <id name="accountId" column="tuan_account_id" length="50" type="integer"> <generator column="tuan_account_money" length="200" not-null="true" type="big_decimal" scale="2"/> <property name="accountLockMoney" column="tuan_account_lock_money" length="20" not-null="true" type="big_decimal" scale="2" /> <property name="accountCreateDate" column="tuan_account_create_date" length="20" not-null="true" type="timestamp"/> <many-to-one name="person" column="tuan_account_person_id" not-null="true"/> </class></hibernate-mapping>
SQL> desc tuan_account;Name Type Nullable Default Comments ------------------------ ------------ -------- ------- -------- TUAN_ACCOUNT_ID NUMBER(10) TUAN_ACCOUNT_MONEY NUMBE(19,2) TUAN_ACCOUNT_LOCK_MONEY NUMBER(19,2) TUAN_ACCOUNT_CREATE_DATE DATE SQL>