- 方法
Employee selectByIdAndLastname(Integer id,String lastName);
- 取值
<select id="selectByIdAndLastname" resultType="com.paul.mybatis.pojo.Employee">
select * from employee where id =#{id} and last_name=#{lastName}
</select>
- 结果
Caused by: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [arg1, arg0, param1, param2]
- 分析
mybatis在处理多个参数的时候,会使用map进行封装,其中
键为:param0......paramN
值:实际参数值
- 解决方法1:
使用param0.....paramN 进行取值,或者是参数索引
- 解决方法2:
使用具名参数,将方法进行修改如下
Employee selectByIdAndLastname(@Param("id") Integer id, @Param("lastName")String lastName);