ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Abator new Generator Set
Date Tue, 26 Sep 2006 14:30:02 GMT
Hi Emiliano,

You are correct - you are using the Criteria class in just the way I had
envisioned.  But I (obviously) didn't account for the case where there are
no criteria set :(  I'll fix it for the next release.  The workaround for
now would be to not create the criteria class if there will be no criteria
set.  I know this is an imperfect solution, but it will work for now.

There is no "example.and(Criteria)" method because the current setup already
allows any WHERE clause to be generated - there's no need for it.  You can
do as many ANDs as you want - in exactly the way you are doing it, and you
can add as many ORs as you want too.

Jeff Butler



On 9/26/06, Emiliano Armellin <earmellin@ateikon.com> wrote:
>
> Hello,
>
> I have to add different *and* clauses in different place of my code, 0 or
> more and clauses...
>
> Which is the correct way to do it?
>
> My solution is this:
>
>             TableExample.Criteria criteria = example.createCriteria();
>
>             if(StringUtils.isNotBlank(field1)){
>                 criteria.andField2EqualTo(field1);
>             }
>
>             if(StringUtils.isNotBlank(field2)){
>                 criteria.andField2EqualTo(field2);
>             }
>
> this solution does not work if field1 & field2 are empty, it creates an
> empty clause  (   )
>
> Why does not exist an example.and(criteria) method?
>
>
> --
> Emiliano Armellin
>
>    - W_
>    www.ateikon.com
>    - @_
>    earmellin@ateikon.com
>    - T_
>    *+39 0422 452101*
>
> [image: Get Firefox!]<http://www.spreadfirefox.com/?q=affiliates&id=15653&t=86>
> [image: Get Thunderbird] <http://www.mozilla.org/products/thunderbird/>
>

Mime
View raw message