ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jared Blitzstein <ja...@blitzstein.net>
Subject Re: Question about Abator and Java5 example building, I can't add a second and clause
Date Sun, 10 Feb 2008 20:12:41 GMT
Perfect, thank you.

On Feb 10, 2008, at 3:03 PM, Jeff Butler wrote:

> Try this:
>
> Example example = new Example();
> Criteria criteria = example.createCriteria();
> if (a == b) {
>   criteria.andField1EqualTo(5);
> }
>
> if (c == f) {
>   criteria.andField2EqualTo(5);
> }
>
> Jeff Butler
>
>
> On Feb 10, 2008 1:56 PM, Jared Blitzstein <jared@blitzstein.net>  
> wrote:
> I have a case where I need to do some "if" logic before I know to  
> add an and statement. I have a snippet like this:
>
> Example example = new Example();
>
> if (a==b) {
>   example.createCriteria().andField1EqualTo(5);
> }
>
> if (c==f) {
>   example.createCriteria().andField2EqualTo(5);
> }
>
> Doing this results in only one where clause,  "where Field1 = 5" and  
> not like "where Field1 = 5 and Field2 = 5" like I want. Am I using  
> the correct syntax or is there a different way to do this?  
> Essentially I'm building the where clause based on user input.
>


Mime
View raw message