I am having a problem with a custom UserType in an existing application. The background is that there is a table called Rates with a column called rate. In java we have a Rates.java containing a RateAmount.java. RateAmount extends BigDecimal. Rates.java is for the whole table and RateAmount is for the single column rate.
There is a custom UserType to allow RateAmount to be mapped without using a component.
Generally everything works fine but we have seen cases where the calculations are off and according to our logging it looks like the object is using the table's primary key as the rate. So far I have been unable to reproduce this using the mapping files and java classes in a unit test environment.
The null safe get in the UserType looks like:
public Object nullSafeGet(final ResultSet resultSet, final String[] names, final Object owner)
throws HibernateException, SQLException {
String value = resultSet.getString(names[0]);
if (resultSet.wasNull()) {
return null;
}
return new RateAmount(value);
}
If there was someway for the String[] names to come in with the alias for the primary key?
Has anyone seen anything like this before?
|