前言
略
@Param 指定参数名
mapper:
User getUserByIdAndName(@Param("id") int id,@Param("name") String name);
xml:
<select id="getUserByIdAndName" parameterType="Map" resultType="com.model.User">
select * from user where id = #{id} and name=#{name}
</select>
默认参数名
3.4.2之后:
- 用#{arg0}、#{arg1}、…表示参数1、参数2、…
- 用#{param1}、#{param2}、…表示参数1、参数2、…
mapper:
User getUserByIdAndName(int id, String name);
xml:
<select id="getUserByIdAndName" parameterType="Map" resultType="com.model.User">
select * from user where id = #{arg0} and name=#{arg1}
</select>
或者
<select id="getUserByIdAndName" parameterType="Map" resultType="com.model.User">
select * from user where id = #{param1} and name=#{param2}
</select>
3.4.2之前,默认参数名
3.4.2之前:
- 用#{0}、#{1}、…表示参数1、参数2、…
- 用#{param1}、#{param2}、…表示参数1、参数2、…
mapper:
User getUserByIdAndName(int id, String name);
xml:
<select id="getUserByIdAndName" parameterType="Map" resultType="com.model.User">
select * from user where id = #{0} and name=#{1}
</select>
或者
<select id="getUserByIdAndName" parameterType="Map" resultType="com.model.User">
select * from user where id = #{param1} and name=#{param2}
</select>
|