[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2135) Hibernate Deserialization: In org.hibernate.type.SerializableType the code makes a test for the return of a null object by simply testing the object as to whether or not it is null.

Steve Ebersole (JIRA) noreply at atlassian.com
Thu Oct 5 13:55:24 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2135?page=comments#action_24736 ] 

Steve Ebersole commented on HHH-2135:
-------------------------------------

This is an error in the JDBC driver.  The definition of ResultSet.getBytes() explicitly states that it should return NULL when the DB value is NULL.  But it is trivial to add the extra check which will not even impact JDBC drivers which implement this correctly.

> Hibernate Deserialization:  In org.hibernate.type.SerializableType the code makes a test for the return of a null object by simply testing the object as to whether or not it is null.
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HHH-2135
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2135
>      Project: Hibernate3
>         Type: Improvement

>     Versions: 3.2.0.cr5
>  Environment: HIbernate 3.2.1 & NCR TeradataJBOss 4.0.x & JBoss Cache 1.2.4
>     Reporter: Lamon Gray

>
>
> In org.hibernate.type.SerializableType the code makes a test for the return of a null object by simply testing the object as to whether or not it is null.
> public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
> byte[] bytes = (byte[]) Hibernate.BINARY.get(rs, name);
> if ( bytes==null) {
> return null;
> }
> else {
> return fromBytes(bytes);
> }
> }
> Fairly reasonable, however in my testing of the Teradata dialect i am finding that often the value in the column is null but that the return is coming back as an empty array. The following code would seem to be a bit more robust in my opinion:
> public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
> byte[] bytes = (byte[]) Hibernate.BINARY.get(rs, name);
> if ( bytes==null || Array.getLength(bytes)==0) {
> return null;
> }
> else {
> return fromBytes(bytes);
> }
> }
> Can someone tell me if this is done this way for a reason? Or maybe the JDBC driver is returning the incorrect value (IE. it should be returning a null value as opposed to an empty array)?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list