-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: MonetaryAmountUserType - why resultSet.wasNull() ?
PostPosted: Fri Feb 18, 2005 8:43 am 
Newbie

Joined: Sat Nov 20, 2004 5:24 am
Posts: 2
Location: Edinburgh, Scotland
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 19, 2005 4:35 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please chech the errata first.


Top
 Profile  
 
 Post subject: re: MonetaryAmountUserType - why resultSet.wasNull()
PostPosted: Sat Feb 19, 2005 5:18 am 
Newbie

Joined: Sat Nov 20, 2004 5:24 am
Posts: 2
Location: Edinburgh, Scotland
My apologies.

I had checked the latest 0.9.5 source (which is unchanged) rather than the errata.

Mike E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.