Hi,
In Progress we have boolean in Oracle integer.
In Progress we have integer in Oracle big_decimal.
How the default here is progress. I'm trying to do
a UserType to do this convertions at runtime.
BigDecimal to Integer ( Loading )
Integer to BigDecimal ( Saving )
Code:
public class NumericUserType implements UserType {
private static final int[] SQL_TYPE = { Types.NUMERIC };
/**
* {@link UserType#sqlTypes()}
*/
public int[] sqlTypes() {
return SQL_TYPE;
}
/**
* {@link UserType#returnedClass()}
*/
public Class returnedClass() {
return DispositControlAces.class;
}
/**
* {@link UserType#equals(Object, Object)}
*/
public boolean equals(Object obj0, Object obj1) throws HibernateException {
return EqualsBuilder.reflectionEquals(obj0, obj1);
}
/**
* {@link UserType#hashCode(Object)}
*/
public int hashCode(Object obj0) throws HibernateException {
return HashCodeBuilder.reflectionHashCode(obj0);
}
/**
* {@link UserType#nullSafeGet(ResultSet, String[], Object)}
*/
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException {
Integer integer = resultSet.getBigDecimal(names[0]).intValue();
return integer;
}
/**
* {@link UserType#nullSafeSet(PreparedStatement, Object, int)}
*/
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
if (value == null) {
preparedStatement.setNull( index, Types.NUMERIC );
} else {
preparedStatement.setBigDecimal(index, new BigDecimal( ((Integer)value).intValue() ) );
}
}
/**
* {@link UserType#deepCopy(Object)}
*/
public Object deepCopy(Object obj0) throws HibernateException {
return obj0;
}
/**
* {@link UserType#isMutable()}
*/
public boolean isMutable() {
return false;
}
/**
* {@link UserType#disassemble(Object)}
*/
public Serializable disassemble(Object arg0) throws HibernateException {
return (Serializable) this.deepCopy( arg0 );
}
/**
* {@link UserType#assemble(Serializable, Object)}
*/
public Object assemble(Serializable arg0, Object arg1) throws HibernateException {
return this.deepCopy(arg0);
}
/**
* {@link UserType#replace(Object, Object, Object)}
*/
public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException {
return this.deepCopy(arg0);
}
}
This class is ok?
Thanks.