ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gwyn Evans" <gwyn.ev...@gmail.com>
Subject Re: Abator new Generator Set
Date Wed, 27 Sep 2006 16:56:20 GMT
Hi Jeff,
  One minor issue I had (till I refactored) in this area was that at one
point I set some criteria in a base class, but sometimes wanted to set some
additional "AND" clauses in a derived class.  As such, I there needed to
re-obtain the (single) Criteria instance, (which I did via
example.getOredCriteria().get(0)), but wondered if there was/should be a
better way that that?

/Gwyn

On 26/09/06, Jeff Butler <jeffgbutler@gmail.com> wrote:
>
> 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/>
> >
>
>


-- 
Download Wicket 1.2.2 now! - http://wicketframework.org

Mime
View raw message