ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Iwao AVE!" <haraw...@gmail.com>
Subject Re: Null handling of Ibator's Criteria class.
Date Wed, 22 Apr 2009 17:38:49 GMT
Yes, the fix allows me to remove some extra lines.

// Iwao

on 09.4.23 2:12 AM Jeff Butler said the following:
> 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! <harawata@gmail.com>:
>> 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.  It'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
>>> <zoran@sparecreative.com> wrote:
>>>> The simple solution we’ve implemented is to modify the source to ignore
>>>> values. That way we don’t have to do null checks and it simplifies the
>>>> process of of building dynamic queries. You have two options you can modify
>>>> the source after Ibator has run or modify the Ibator source code. We opted
>>>> for the second option, but I can understand why some people might not want
>>>> to modify the Ibator source.
>>>> I’m pretty sure your example below won’t work as only the last criteria
>>>> added will be used. It’s been a while since I looked at it so I’m not
>>>> 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 to
>>>> check null for each condition.
>>>> Criteria criteria = someExample.createCriteria();
>>>> if (condition1 != null)
>>>>   criteria.andCondition1EqualTo(condition1);
>>>> if (condition2 != null)
>>>>   criteria.andCondition1EqualTo(condition2);
>>>> ...
>>>> Basically, I want criteria classes to ignore null value (i.e. not to add
>>>> 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

View raw message