-->
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: resultSet.wasNull() in UserType implementation
PostPosted: Tue Oct 12, 2004 10:56 am 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
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: error in HIA sample code
PostPosted: Mon Feb 28, 2005 9:28 am 
Newbie

Joined: Wed Feb 25, 2004 10:43 am
Posts: 14
Hello,

this is an obvious error in the example code, which needs to be fixed asap IMO, as it might seriously frustrate new hibernate users.

The line resultSet.wasNull() must appear AFTER the line with the getXXX, of course, as below:

BigDecimal valueInUSD = resultSet.getBigDecimal(names[0]);
if (resultSet.wasNull()) return null
else
return new MonetaryAmount(valueInUSD, Currency.getInstance)"USD"));
}

this is on page 204.
christian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 10:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is already in the errata list.


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.