<select id="demo" resultMap="User">
select *
from user where user_id=#{0} and name= #{1}
</select>
jdk1.8之后
第一种写法
<select id="demo" resultMap="User">
select *
from user where user_id=#{arg0} and name= #{arg1}
</select>
第二种写法
<select id="demo" resultMap="User">
select *
from user where user_id=#{param0} and name= #{param1}
</select>
方法2:@Param注解传参法
public User selectUser(@Param("userName") String name, int @Param("deptId") deptId);
<select id="selectUser" resultMap="UserResultMap">
select * from user
where user_name = #{userName} and dept_id = #{deptId}
</select>
public User selectUser(Map<String, Object> params);
<select id="selectUser" parameterType="java.util.Map" resultMap="UserResultMap">
select * from user
where user_name = #{userName} and dept_id = #{deptId}
</select>
public User selectUser(User user);
<select id="selectUser" parameterType="com.test.User" resultMap="UserResultMap">
select * from user
where user_name = #{userName} and dept_id = #{deptId}
</select>