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

项目: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);
    }
}
项目:resthub    文件:Handler.java   
public void applyParameters(SQLQuery query) throws SQLException {
    for (Map.Entry<QueryParameter, Object> e : parameters.entrySet()) {

        QueryParameter p = e.getKey();
        Object value = e.getValue();
        String name = p.getSqlName();

        if (value != null && p.getArray()) {

            switch (p.getType()) {
                case DATE:
                    query.setParameterList(name, (Object[]) value, new DateType());
                    break;
                case NUMBER:
                    query.setParameterList(name, (Object[]) value, new BigDecimalType());
                    break;
                case STRING:
                    query.setParameterList(name, (Object[]) value, new StringType());
                    break;
                case CLOB:
                case BLOB:
                    throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("LOBs are not supported as parameters: %s", name));
            }

        } else {

            switch (p.getType()) {
                case DATE:
                    query.setDate(name, (Date) value);
                    break;
                case NUMBER:
                    query.setBigDecimal(name, (BigDecimal) value);
                    break;
                case STRING:
                    query.setString(name, (String) value);
                    break;
                case CLOB:
                case BLOB:
                    throw new ClientErrorException(Status.CLIENT_ERROR_BAD_REQUEST, String.format("LOBs are not supported as parameters: %s", name));
            }
        }
    }
}
项目:jadira    文件:AbstractBigDecimalColumnMapper.java   
@Override
public final BigDecimalType getHibernateType() {
    return StandardBasicTypes.BIG_DECIMAL;
}
项目:debop4j    文件:MonetaryAmountCompositeUserType.java   
@Override
public Type[] getPropertyTypes() {
    return new Type[] { BigDecimalType.INSTANCE, CurrencyType.INSTANCE };
}