select * from user where sex = 1 and username = "Jack";
<!-- 对应Mapper.xml SQL语句 -->
<select id="selectUserBySexAndUserName" resultMap="UserExample" parameterType="com.huarenwenyu.client.dao.UserExample">
select * from user
<where>
<if test="sex != null and sex != ''">
sex = #{sex} and
</if>
<if test="username != null and username != ''">
username = #{username}
</if>
</where>
</select>
<!-- 测试代码 -->
User user = new User();
//user.setSex("1");
user.setUsername("Jack");
List<User> users = userMapper.selectUserBySexAndUserName(user);
for (User user2 : users) {
System.out.println(user2);
}