<selectid="getUsersByNameAndPassword"resultType="com.wy.bean.User">
SELECT * FROM users WHERE username = #{username} AND PASSWORD = #{password}
</select>
publicvoidtestGetUsersByNameAndPassword(){
SqlSession session = MyBatisUtils.getSession();
UserDao userDao = session.getMapper(UserDao.class);
User user =newUser();
user.setUsername("张三");
user.setPassword("1000");
System.out.println(userDao.getUsersByNameAndPassword(user));
MyBatisUtils.close(session);}
2.2 可以通过map进行传递
User getUserByNameAndPassword2(Map<String, Object> map);
<selectid="getUserByNameAndPassword2"resultType="com.wy.bean.User">
SELECT * FROM users WHERE username = #{username} AND PASSWORD = #{password}
</select>