mybatis Example条件查询

来源:互联网 发布:linux编译链接 编辑:程序博客网 时间:2024/06/14 04:18

Criterion是最基本,最底层的Where条件,用于字段级的筛选


  • Criteria

Criteria包含一个Cretiron的集合,每一个Criteria对象内包含的Cretiron之间是由AND连接的,是逻辑与的关系。

oredCriteria

Example内有一个成员叫oredCriteria,是Criteria的集合,就想其名字所预示的一样,这个集合中的Criteria是由OR连接的,是逻辑或关系。oredCriteria就是ORed Criteria。

其他

Example类的distinct字段用于指定DISTINCT查询。

orderByClause字段用于指定ORDER BY条件,这个条件没有构造方法,直接通过传递字符串值指定。

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


原创粉丝点击