我想用 MyBatis 创建一个查询,它会产生如下内容:
SELECT first_field, second_filed, third_field
WHERE first_field > 1 AND (second_field > 0 OR third_field < 0)
我如何使用 Criteria 对象构造它?
请您参考如下方法:
因为 a AND (b OR c) 与 (a AND b) or (a AND c) 相同
TestTableExample example = new TestTableExample();
example.createCriteria()
.andField1GreaterThan(1)
.andField2GreaterThan(0);
example.or(example.createCriteria()
.andField1GreaterThan(1)
.andField3LessThan(0));
然后坐下来让 SQL 优化器解决。






