nullSafeGet not null safe
-------------------------

         Key: HIB-103
         URL: http://jira.andromda.org/browse/HIB-103
     Project: Hibernate Cartridge
        Type: Bug
    Versions: 3.0 Final    
 Environment: HIbernate/Spring cartridge
    Reporter: Darius Schier
 Assigned to: Martin West 


Hi there,
HibernateByteBlobType.nullSafeGet and nullSafeSet are not null save, NPE are 
thrown in both cases if the value is null.
I would suggest something like that:

    public void nullSafeSet(PreparedStatement st, Object value, int index)
        throws SQLException
    {
        byte[] b = (byte[])value;
        if(b!= null ) {
           st.setBinaryStream(index, new ByteArrayInputStream(b), b.length);
        } else {
           st.setBinaryStream(index,null,0);
        }
    }

    public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
        throws SQLException
    {
        Blob blob = rs.getBlob(names[0]);
        if(blob == null) {
            return null;
        } else {
            return blob.getBytes(1, (int)blob.length());
        }
    }


Regards
Darius

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.andromda.org/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Andromda-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-devel

Reply via email to