You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Paul Barry <pa...@nyu.edu> on 2005/05/23 16:35:45 UTC
null BLOB and byte array
I have a BLOB column in my database that can be null. I want to map it
to a byte[], but when I do, I get a NullPointerException. Anyway have a
good way of dealing with this?
Re: null BLOB and byte array
Posted by Paul Barry <pa...@nyu.edu>.
If I change these methods in
com.ibatis.sqlmap.engine.type.BlobTypeHandlerCallback, it works fine:
public Object getResult(ResultGetter getter)
throws SQLException {
Blob blob = getter.getBlob();
if(blob != null) {
int size = (int) blob.length();
return blob.getBytes(1, size);
} else {
return null;
}
}
public void setParameter(ParameterSetter setter, Object parameter)
throws SQLException {
if(parameter != null) {
byte[] bytes = (byte[]) parameter;
setter.setBytes(bytes);
}
}
Nathan Maves wrote:
> Paul,
>
> btye[] are objects so having them be null is just fine.
>
> byte[] test = null;
>
> I am not sure if there is a test case written for this yet.
>
> I will look into it.
>
> Nathan
> On May 23, 2005, at 8:35 AM, Paul Barry wrote:
>
>> I have a BLOB column in my database that can be null. I want to map
>> it to a byte[], but when I do, I get a NullPointerException. Anyway
>> have a good way of dealing with this?
>>
>
Re: null BLOB and byte array
Posted by Nathan Maves <Na...@Sun.COM>.
Paul,
btye[] are objects so having them be null is just fine.
byte[] test = null;
I am not sure if there is a test case written for this yet.
I will look into it.
Nathan
On May 23, 2005, at 8:35 AM, Paul Barry wrote:
> I have a BLOB column in my database that can be null. I want to
> map it to a byte[], but when I do, I get a NullPointerException.
> Anyway have a good way of dealing with this?
>