mybatis学习系列--逆向工程简单使用及mybatis原理
作者:互联网
2逆向工程简单测试(68-70)
SqlSessionFactory sqlSessionFactory=getSqlSessionFactory();
SqlSession session = sqlSessionFactory.openSession();
try {
EmployeeMapper mapper = session.getMapper(EmployeeMapper.class);
//where (emai like ? and gender=?) or (email like ? and gender=?)
EmployeeExample example=new EmployeeExample();
Criteria createCriteria = example.createCriteria();
createCriteria.andEmailLike("%3519%").andGenderEqualTo("1");
Criteria createCriteria2 = example.createCriteria();
createCriteria2.andGenderEqualTo("0");
example.or(createCriteria2);
List<Employee> selectByExample = mapper.selectByExample(example);
for(Employee e:selectByExample) {
System.out.println(e.getEmail()+e.getGender());
}
} finally {
session.close();
}
3mybatis工作原理(71-72)
标签:逆向,系列,createCriteria2,session,selectByExample,createCriteria,Criteria,mybatis,ex 来源: https://www.cnblogs.com/cslj2013/p/10534137.html