[ http://jira.andromda.org/browse/HIB-166?page=comments#action_12460 ]
     
Wouter Zoons commented on HIB-166:
----------------------------------

thanks for your code, I had a change a few things though:

1. nullSafeGet wasn't always returning, I made it return the outputstream's 
.getByteArray()
2. we don't want any dependency to 'Log' so I'm throwing an exception instead

I will be committing this issue's fix very soon, can you give it a try when 
it's closed ?

> CLONE -nullSafeGet not null safe HIB-103
> ----------------------------------------
>
>          Key: HIB-166
>          URL: http://jira.andromda.org/browse/HIB-166
>      Project: Hibernate Cartridge
>         Type: Bug
>     Versions: 3.0 Final
>  Environment: HIbernate/Spring cartridge
>     Reporter: Darius Schier
>     Assignee: Wouter Zoons

>
> 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 SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

Reply via email to