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 <zo...@sparecreative.com> wrote: > 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 > >