> Re: I have a TypeHandler that converts Y/N to boolean, but sometimes Y/N
might be null...
http://www.mail-archive.com/[email protected]/msg04323.html
Hi all
My issue here is a bit different
I have a TypeHandler that loads some string values (a VARCHAR column with a
finite set of strings) and converts then into a Java enum; the column is
nullable.
When the column is null also the corresponding Java enumeration for that
column should be null.
Section 12.2.1 of iBatis in action explains how to map a boolean-like type
into the Java's boolean. Explains valueOf() in terms of null value
replacement.
The case here si diferent
Well, if the column is null I would like here to get a null.
Should i write somethig like
public
Object
getResult( ResultGetter pResultGetter ) throws SQLException
{
String lString = pResultGetter.getString();
MyEnum lResult;
if ( lString == null )
return null;
or should in some way rely on the valueOf()?
Well, controlling the execution by mean of the the debugger I realized
that, valuOf() is not called at all. Instead it holds
pResultGetter.getString() == null
when getResult() is called.
I guess that in this case, valueOf() is unuseful, it won't be called, we
should rely onto getResult() only.
Is that right?
Thanks in advance for any reply
ciao
Cesare