Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 63825 invoked from network); 18 Jun 2007 13:06:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jun 2007 13:06:22 -0000 Received: (qmail 94118 invoked by uid 500); 18 Jun 2007 13:06:24 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 93846 invoked by uid 500); 18 Jun 2007 13:06:23 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 93835 invoked by uid 99); 18 Jun 2007 13:06:23 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jun 2007 06:06:23 -0700 X-ASF-Spam-Status: No, hits=2.5 required=10.0 tests=HTML_MESSAGE,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.103.62.70] (HELO mailgateway.ads.it) (83.103.62.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Jun 2007 06:06:18 -0700 Received: from mailgateway.ads.it (unknown [127.0.0.1]) by mailgateway.ads.it (Symantec Mail Security) with ESMTP id 2685F39801B for ; Mon, 18 Jun 2007 15:04:12 +0200 (CEST) X-AuditID: 0ac5fe14-a3d7bbb000000a4a-f9-467682cc9fd6 Received: from mail.ads.it (unknown [10.97.30.5]) by mailgateway.ads.it (Symantec Mail Security) with ESMTP id 0A27842400B for ; Mon, 18 Jun 2007 15:04:12 +0200 (CEST) Subject: nullable enum columns: valueOf() vs getResult() To: user-java@ibatis.apache.org X-Mailer: Lotus Notes Release 7.0.1 January 17, 2006 Message-ID: From: c.zecca@ads.it Date: Mon, 18 Jun 2007 15:04:32 +0200 X-MIMETrack: Serialize by Router on Mercurio/Minosse(Release 6.5.5|November 30, 2005) at 18/06/2007 03.04.31 PM MIME-Version: 1.0 Content-type: multipart/alternative; Boundary="0__=4EBBF86DDFD6512D8f9e8a93df938690918c4EBBF86DDFD6512D" Content-Disposition: inline X-Brightmail-Tracker: AAAAAA== X-Virus-Checked: Checked by ClamAV on apache.org --0__=4EBBF86DDFD6512D8f9e8a93df938690918c4EBBF86DDFD6512D Content-type: text/plain; charset=US-ASCII > Re: I have a TypeHandler that converts Y/N to boolean, but sometimes Y/N might be null... http://www.mail-archive.com/user-java@ibatis.apache.org/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 --0__=4EBBF86DDFD6512D8f9e8a93df938690918c4EBBF86DDFD6512D Content-type: text/html; charset=US-ASCII Content-Disposition: inline

> Re: I have a TypeHandler that converts Y/N to boolean, but sometimes Y/N might be null...
http://www.mail-archive.com/user-java@ibatis.apache.org/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
--0__=4EBBF86DDFD6512D8f9e8a93df938690918c4EBBF86DDFD6512D--