Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 38970 invoked from network); 22 Apr 2009 17:13:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Apr 2009 17:13:22 -0000 Received: (qmail 25694 invoked by uid 500); 22 Apr 2009 17:13:21 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 25647 invoked by uid 500); 22 Apr 2009 17:13:21 -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 25639 invoked by uid 99); 22 Apr 2009 17:13:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2009 17:13:21 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jeffgbutler@gmail.com designates 209.85.217.157 as permitted sender) Received: from [209.85.217.157] (HELO mail-gx0-f157.google.com) (209.85.217.157) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Apr 2009 17:13:13 +0000 Received: by gxk1 with SMTP id 1so175479gxk.0 for ; Wed, 22 Apr 2009 10:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=UPYfx689Cmp7xF2ki2UATpdTp5bxFYryZzQlPmnbfX0=; b=yBPkqlARTc6+01J0EUlpDSnBZch7BI/Gd6rlChrt0bI5lawcgMIZTPpxE+vdl2jNRW buA6u35NQn3O5QG2Sucfow1tAZTD4XV0eNFlfBe9VI0BZoQJF0P+Rr+3KZl/3Hx0XMjW J+7z9LS8UvWft+sJsVgYka29uTcSW04bNdw0I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=FL0Nzrk3kPyNnjERyAB7ZDq4sBoD8ZWuMRVQX5XGDdQY1MYbBasDylkeXPZ6Jac3YI dpGnAI+Yk0wEc4ZqJiTpzyIq57OMiZFO6izsTqw8W0sLVBKhJykzPN+vFXw7Y5c/zbPX wjB95nnN7EsmBSUiFe4kXDTJMPtjta95vELX0= MIME-Version: 1.0 Received: by 10.151.49.12 with SMTP id b12mr107078ybk.153.1240420370753; Wed, 22 Apr 2009 10:12:50 -0700 (PDT) In-Reply-To: <49EF4C85.5030007@gmail.com> References: <49ED9B61.10509@gmail.com> <49EF4C85.5030007@gmail.com> Date: Wed, 22 Apr 2009 12:12:50 -0500 Message-ID: Subject: Re: Null handling of Ibator's Criteria class. From: Jeff Butler To: user-java@ibatis.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org No - it's not intentional, I'll have to fix that. Plus, fixing it will make the plugin easier - you'll simply have to delete the second line of all addCriterion* methods and replace it with "return;" Jeff Butler 2009/4/22 Iwao AVE! : > Zoran, Jeff, > > Thank you for your reply. > I actually have written a plugin and been using it for a while. > > Considering the characteristics of a tool like Ibator, though, I > thought the default behavior should be ignoring null and wanted to > know how other developers think. > It seems that the plugin is a sufficient solution. > > To Jeff, > While writing the plugin, I noticed that one of the > addCriterionForJDBCDate() method does not throw RuntimeException > when the value is null (NullPointerException is thrown). > Is this intentional? > > Regards, > Iwao > > on 09.4.23 1:11 AM Jeff Butler said the following: >> You cold also write a plugin to change the generated code in the model >> classes. =A0It's a bit more complex than the average plugin, but >> certainly doable. >> >> Jeff Butler >> >> >> On Tue, Apr 21, 2009 at 6:39 PM, Zoran Avtarovski >> wrote: >>> The simple solution we=92ve implemented is to modify the source to igno= re null >>> values. That way we don=92t have to do null checks and it simplifies th= e >>> process of of building dynamic queries. You have two options you can mo= dify >>> the source after Ibator has run or modify the Ibator source code. We op= ted >>> for the second option, but I can understand why some people might not w= ant >>> to modify the Ibator source. >>> >>> I=92m pretty sure your example below won=92t work as only the last crit= eria >>> added will be used. It=92s been a while since I looked at it so I=92m n= ot >>> certain. >>> >>> Z. >>> >>> >>> Hi all, >>> >>> A Criteria inner class generated by Ibator throws RuntimeException when >>> addCriterion() or addCriterionForJDBCDate() method is called with null >>> as its 'value' argument. >>> As a result of this behavior, when I build a dynamic criteria, I have t= o >>> check null for each condition. >>> >>> Criteria criteria =3D someExample.createCriteria(); >>> if (condition1 !=3D null) >>> =A0 criteria.andCondition1EqualTo(condition1); >>> if (condition2 !=3D null) >>> =A0 criteria.andCondition1EqualTo(condition2); >>> ... >>> >>> Basically, I want criteria classes to ignore null value (i.e. not to ad= d >>> any criteria). >>> When some condition is required, I would validate it in another way >>> (presentation framework's validation feature, for example). >>> >>> Before opening a new issue on JIRA, I would like to hear from other >>> Ibator users about the behavior. >>> What do you think? >>> >>> Thanks, >>> Iwao >