[jrf-user] Nullable Blobs
Brought to you by:
joncrlsn
|
From: Cinq - G. P. de O. <g.p...@ci...> - 2002-11-20 01:29:31
|
<P>Hi,</P> <P>I was using Blobs with JRF and MySql. I had problems when my blob column was nullable (new NullableColumnOption() in my setup method).<BR>When it is null and I tried to save it, I got a NullPointerException. It happened because the method getColumnValueFrom in the net.sf.jrf.column.columnspecs.BlobColumnSpec class was not testing if the BlobWrapper is null or not:</P> <P>BlobWrapper b = (BlobWrapper) value;<BR>b.storeData(stmt, position, super.i_sqlType);</P> <P>when b is null, I get a NullPointerException.</P> <P><BR>I've found a very simple solution: verify if b is not null:</P> <P>BlobWrapper b = (BlobWrapper) value;<BR>if (b != null)<BR> b.storeData(stmt, position, super.i_sqlType);<BR>else<BR> stmt.setNull(position, null, super.i_sqlType);</P> <P><BR>I did the same thing when this is selected from the database in the getColumnValueFrom from the same class:</P> <P>Blob value = jrfResultSet.getBlob(this.getColumnIdx());<BR>return (value == null ? null : new BlobWrapper(value));</P> <P><BR>Am I wrong? Did someone have this problem?</P> <P>I am using the 'IBM Websphere Studio Application Developer' to program.</P> <P>Thanks</P> <P><BR>Glaucio</P><br> <br> __________________________________<br> Cinq Technologies - http://www.cinq.com.br<br> |