Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 51766 invoked from network); 9 Feb 2007 18:38:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2007 18:38:44 -0000 Received: (qmail 72195 invoked by uid 500); 9 Feb 2007 18:38:48 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 72178 invoked by uid 500); 9 Feb 2007 18:38:48 -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 72167 invoked by uid 99); 9 Feb 2007 18:38:48 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Feb 2007 10:38:48 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of Daniel.Pitts@cnet.com designates 216.239.124.18 as permitted sender) Received: from [216.239.124.18] (HELO cn-sfo1-mail-relay2.cnet.com) (216.239.124.18) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Feb 2007 10:38:38 -0800 Received: from cnet138.cnet.cnwk (cnet138.cnet.cnwk [10.16.0.65]) by cn-sfo1-mail-relay2.cnet.com (8.12.10/8.12.10) with ESMTP id l19IcHAm011948 for ; Fri, 9 Feb 2007 10:38:17 -0800 (PST) X-Spam-Filter: check_local@cn-sfo1-mail-relay2.cnet.com by digitalanswers.org Received: from CNET6.cnet.cnwk ([10.16.0.103]) by cnet138.cnet.cnwk with Microsoft SMTPSVC(6.0.3790.1830); Fri, 9 Feb 2007 10:38:17 -0800 x-mimeole: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Map nullValue to empty collection Date: Fri, 9 Feb 2007 10:38:16 -0800 Message-ID: <7E4302A18925394BAC32C7AD1ABE75D401536E81@CNET6.cnet.cnwk> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Map nullValue to empty collection Thread-Index: AcdML8MiIkrxhVu6SQG1nXs+1MhcPwASVkoQ References: From: "Daniel Pitts" To: X-OriginalArrivalTime: 09 Feb 2007 18:38:17.0440 (UTC) FILETIME=[76FD1600:01C74C79] X-Virus-Checked: Checked by ClamAV on apache.org Depending on whether you need to be able to "add/remove" from the Objects list after its set: public void setObjects(List objects) { this.objects =3D objects =3D=3D null ? Collections.emptyList() : = objects; }=20 // or public void setObjects(List objects) { this.objects =3D objects =3D=3D null ? new ArrayList() : = objects; }=20 -----Original Message----- From: news [mailto:news@sea.gmane.org] On Behalf Of Stephane Bailliez Sent: Friday, February 09, 2007 1:49 AM To: user-java@ibatis.apache.org Subject: Map nullValue to empty collection I have a setter which does no accept null values for a list, ie: public void setObjects(List objects){ if (objects =3D=3D null) throw new NullPointerException("null not permitted"); this.objects =3D objects; } I did not find yet any decent way to map a nullvalue to an empty list, I was thinking of using a specific TypeHandlerCallback on this property on the result map but did not go this route yet. For now dumbest thing I could do was to remove the check and do nothing if objects is null, other possibility include an intermediate holder object...or ? Any suggestions welcome. -- stephane