The simple solution we¹ve implemented is to modify the source to ignore null
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


Reply via email to