-->
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.  [ 1 post ] 
Author Message
 Post subject: FYI: UserType, nullSafeGet and resultSet.wasNull() check
PostPosted: Fri Jan 07, 2005 12:45 pm 
Newbie

Joined: Wed Jan 05, 2005 9:08 am
Posts: 3
[b]Hibernate version:2.1.7[/b]

[b]Name and version of the database you are using:Oracle 9[/b]

In case of coding a UserType "Hibernate in Action" proposes a immediate resultSet.wasNull() check on entry of UserType.nullSafeGet.

It would look like
[code]
public Object nullSafeGet(ResultSet inRSet, String[] inNames, Object inOwner) throws HibernateException,
SQLException {
if (inRSet.wasNull()) {
return null;
}
[/code]

This fails whenever you have a Select with a projection of only one column which is mapped to the user type, like

[code]
Select usertype-column from BLA bla where bla.id like ?")
[/code]

Obviously there wasn't any read to the ResultSet before entering the nullSafeGet Method. In this case wasNull() must throw en exception according to it's JavaDoc.

Conclusion: Don't use Method entry check as proposed.


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

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.