Hi,
In the reference MonetaryAmountUserType the first line in the nullSafeGet() method is
Code:
if (resultSet.wasNull()) return null;
Hence the return is null whenever the
previous value in the result set is null. This has been a problem to me resolved only by commenting this out.
The CaveatEmptor code has not changed even with the latest release hence this wasNull() check must be deliberate.
Can anyone explain the purpose of / reasoning behind this line?
I found the following post from about a year ago, but no replies.
Thanks in advance,
Mike E.
Anodos wrote:
I've been reading through HiA and love it! Thanks for the excellent resource. Concerning implementing a customer UserType (or CompositeUserType) I notice that the first line in the implementation for "nullSafeGet" is:
Code:
if (resultSet.wasNull()) return null;
I was surprised to see this, as "wasNull()" operates on the last value retrieved from the ResultSet, and there doesn't seem to be any documentation on the last value Hibernate would have retrieved from the ResultSet (if any) before calling "nullSafeGet" on your UserType. I couldn't even find it mentioned in HiA. So my question is, when implementing my own custom UserType, do I need to put this line in my nullSafeGet? If so, what does this line accomplish? Is there some gaurantee somewhere that Hibernate retrieves some standard field before calling nullSafeGet?
Thanks,
Anodos