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)