My current mybatis mapper.xml
is
<select id="batchSelect" resultMap="ResultMap">
select id, user_id, mall_id, log, log_type
from user_log
where user_id in (
<foreach collection="userList" index="index" item="item" separator=",">
#{item,jdbcType=VARCHAR}
</foreach>
) and mall_id = #{1}
</select>
the java Mapper.java
is
List<UserLog> batchSelect(List<String> userList, Long mallId);
When I start spring-boot service, the exception is:
exception: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userList' not found. Available parameters are [0, 1, param1, param2]
How can I write this correctly ?
you can use the annonation @Param
List<UserLog> batchSelect(@Param("userList")List<String> userList, @Param("mailId")Long mallId);
<select id="batchSelect" resultMap="ResultMap">
select id, user_id, mall_id, log, log_type
from user_log
where user_id in (
<foreach collection="userList" index="index" item="item" separator=",">
#{item,jdbcType=VARCHAR}
</foreach>
) and mall_id = #{mailId}
</select>
actually, mybatis-generator supprot selectByExample
, updateByExample
, they all support where in
clause.
this is my final choice
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.