Java 类org.hibernate.type.CurrencyType 实例源码

项目:debop4j    文件:MonetaryAmountCompositeUserType.java   
@Override
public void nullSafeSet(PreparedStatement st,
                        Object value,
                        int index,
                        SessionImplementor session)
        throws HibernateException, SQLException {

    if (value == null) {
        st.setNull(index, BigDecimalType.INSTANCE.sqlType());
        st.setNull(index + 1, CurrencyType.INSTANCE.sqlType());
    } else {
        MonetaryAmount ma = (MonetaryAmount) value;
        String currencyCode = ma.getCurrency().getCurrencyCode();
        st.setBigDecimal(index, ma.getAmount());
        st.setString(index + 1, currencyCode);
    }
}
项目:debop4j    文件:MonetaryAmountCompositeUserType.java   
@Override
public Type[] getPropertyTypes() {
    return new Type[] { BigDecimalType.INSTANCE, CurrencyType.INSTANCE };
}