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 <[EMAIL PROTECTED]> 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

Reply via email to