-->
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: nullSafeGet resultSet.wasNull() should NOT be used
PostPosted: Mon Mar 12, 2007 6:38 am 
Newbie

Joined: Thu Jul 06, 2006 8:04 am
Posts: 14
Hibernate version: 3.2.1.ga

Database: MySQL - innodb 5.x

Following the Hibernate examples, wasNull below should tell me if the value from the database for this column is null.

public Object nullSafeGet(...) throws SQLException {
if (resultsSet.wasNull()) return null;
....
}

However, in my example at least, the test is for the WRONG column, the previous and not the current one.

The caller of nullSafeGet is hydrate at line 2046, from the class org.hibernate.persister.entity.AbstractEntityPersister
public Object[] hydrate(...) {
...
values[i] = types[i].hydrate( propertyResultSet, cols, session, object );
}

Hydrate looks at the types array which relates to the types of the EntityMetamodel for the target, and passes the resultset to the nullSafeGet along with the column name for the UserType in cols[0]. However, I notice that the types and columns arrays differs to the resultSet in number of columns since the resultSet contains an index for the identifier of the record at the start of its collection, but the others do not. As such the indexes are mis-aligned. I have not studied further up the chain from hydrate, but it seems that this could be the culprit of wasNull referring to a different (previos) value?

The mapping file does nothing complicated - the only relevant bit is the start:
<id name="id" column="id" type="long" unsaved-value="null">
<generator class="identity"/>
</id>
<version name="version" column="version"/>
<property name="usersId"/>

Does this look right, or am I completely missing something here?

adam


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.