Example usage for org.hibernate.type StandardBasicTypes CURRENCY

List of usage examples for org.hibernate.type StandardBasicTypes CURRENCY

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes CURRENCY.

Prototype

CurrencyType CURRENCY

To view the source code for org.hibernate.type StandardBasicTypes CURRENCY.

Click Source Link

Document

The standard Hibernate type for mapping java.util.Currency to JDBC java.sql.Types#VARCHAR VARCHAR .

Usage

From source file:org.jboss.as.test.compat.jpa.hibernate.transformer.MonetaryAmountUserType.java

License:Open Source License

public Type[] getPropertyTypes() {
    return new Type[] { StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
}

From source file:org.jboss.as.test.compat.jpa.hibernate.transformer.MonetaryAmountUserType.java

License:Open Source License

public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor 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 MonetaryAmount(amt, cur);
}

From source file:org.jboss.as.test.compat.jpa.hibernate.transformer.MonetaryAmountUserType.java

License:Open Source License

public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor 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);
}