mybati的xml中sql 当传入多个类型不同的参数,目前知道有4种方法:
1. 把参数按照key-value的格式存入map,参数类型为map
2. 把参数封装成POJO,参数类型为实体类型
3. 可以按照占位符的方式;如下
<select id="selectOne" resultMap="ResultMap">
select * from user where user_name = #{0} and user_area=#{1}
</select>
4. 如果参数类型不同,可以用@Param的方式
mapper接口:
Public User selectUser(@param(“userName”)Stringname,@param(“userArea”)String area);
xml中: <select id=" selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_area=#{userArea,jdbcType=VARCHAR}
</select>