package com.iot.mybatis.po;
/**
* Created by Brian on 2016/2/24.
*/
public class UserQueryVo {
//在这里包装所需要的查询条件
//用户查询条件
private UserCustom userCustom;
public UserCustom getUserCustom() {
return userCustom;
}
public void setUserCustom(UserCustom userCustom) {
this.userCustom = userCustom;
}
//可以包装其它的查询条件,订单、商品
//....
}
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'UserCustom' in 'class com.iot.mybatis.po.UserQueryVo'
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'UserCustom' in 'class com.iot.mybatis.po.UserQueryVo'
mapper.java
//用户信息综合查询
public List findUserList(UserQueryVo userQueryVo) throws Exception;
测试代码
//用户信息的综合 查询
@Test
public void testFindUserList() throws Exception {
SqlSession sqlSession = sqlSessionFactory.openSession();
//创建UserMapper对象,mybatis自动生成mapper代理对象
UserMapper userMapper sqlSession.getMapper(UserMapper.class);
//创建包装对象,设置查询条件
UserQueryVo userQueryVo = new UserQueryVo();
UserCustom userCustom = new UserCustom();
//由于这里使用动态sql,如果不设置某个值,条件不会拼接在sql中
userCustom.setSex("1");
userCustom.setUsername("张三");
userQueryVo.setUserCustom(userCustom);
//调用userMapper的方法
List list = userMapper.findUserList(userQueryVo);
System.out.println(list);
}