use of java.util.Currency in project hibernate-orm by hibernate.
the class TypeTest method testCurrencyType.
@Test
public void testCurrencyType() {
final Currency original = Currency.getInstance(Locale.US);
final Currency copy = Currency.getInstance(Locale.US);
final Currency different = Currency.getInstance(Locale.UK);
runBasicTests(CurrencyType.INSTANCE, original, copy, different);
}
use of java.util.Currency in project hibernate-orm by hibernate.
the class MonetaryAmountUserType method nullSafeSet.
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
MonetaryAmount ma = (MonetaryAmount) value;
BigDecimal amt = ma == null ? null : ma.getAmount();
Currency cur = ma == null ? null : ma.getCurrency();
StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
use of java.util.Currency in project hibernate-orm by hibernate.
the class MonetoryAmountUserType method nullSafeSet.
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
MonetoryAmount ma = (MonetoryAmount) value;
BigDecimal amt = ma == null ? null : ma.getAmount();
Currency cur = ma == null ? null : ma.getCurrency();
StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
use of java.util.Currency in project hibernate-orm by hibernate.
the class MonetoryAmountUserType method nullSafeGet.
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet(rs, names[0], session);
Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet(rs, names[1], session);
if (amt == null)
return null;
return new MonetoryAmount(amt, cur);
}
use of java.util.Currency in project hibernate-orm by hibernate.
the class MonetaryAmountUserType method nullSafeSet.
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
MonetaryAmount ma = (MonetaryAmount) value;
BigDecimal amt = ma == null ? null : ma.getAmount();
Currency cur = ma == null ? null : ma.getCurrency();
StandardBasicTypes.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
StandardBasicTypes.CURRENCY.nullSafeSet(st, cur, index + 1, session);
}
Aggregations