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
Get Firefox!
Get Thunderbird

Reply via email to