@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); } }
@Override public Type[] getPropertyTypes() { return new Type[] { BigDecimalType.INSTANCE, CurrencyType.INSTANCE }; }