Criterion是最基本,最底层的Where条件,用于字段级的筛选
-
Criteria
public Employee getEmp(String empName) {
EmployeeExample example = new EmployeeExample();
example.or().andEmpNameEqualTo(empName);
List<Employee> list = employeeMapper.selectByExample(example);
return list.size() > 0 ? list.get(0) : null;
}
运行SQL:
==> Preparing: select emp_id, emp_name, gender, email, d_id from tbl_emp WHERE ( emp_name = ? )
==> Parameters: f4f3510008(String)
<== Columns: emp_id, emp_name, gender, email, d_id
<== Row: 70010, f4f3510008, M, f4f3510008@kerryprops.com, 1
<== Total: 1
本文介绍了MyBatis中Criteria和Criterion的使用方法,包括如何进行字段级筛选、逻辑与及逻辑或组合查询等。此外还说明了如何指定DISTINCT查询及ORDER BY排序。
1975

被折叠的 条评论
为什么被折叠?



