MyBatis传入参数为List对象
生活随笔
收集整理的這篇文章主要介紹了
MyBatis传入参数为List对象
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Dao層接口:List<EntryResource> findByRidAndType(List<EntryResource> entryResources);XML語句:<select id="findByRidAndType" resultMap="entryResource" parameterType="list">SELECT*FROMt_entry_resource aWHERE
<foreach collection="list" index="index" item="entryResources" open="(" close=")" separator="or">( `type`=#{entryResources.type} and resource_id=#{entryResources.resourceId} )
</foreach></select>
(1) select count(*) from users id in (x1,x2,x3,...)
<select id="countByUserList" resultType="int" parameterType="list">
select count(*) from users <where> id in <foreach item="item" collection="list" separator="," open="(" close=")" index=""> #{item.id, jdbcType=NUMERIC} </foreach> </where>
</select>
?
總結
以上是生活随笔為你收集整理的MyBatis传入参数为List对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xxl-job执行定时job原理
- 下一篇: SpringBoot异常处理-自定义错误