【MyBatis】In查询写法

函数:

List<Variable>  searchVarsInNames(@Param("names") List<String> names,@Param("uid") long uid);

 

Mapper.xml:

<select id="searchVarsInNames" resultType="com.hyt.myapp.entity.Variable">

    select ....

    from ....

    where create_uid=#{uid}

    and name in

        <foreach collection="names" item="name" index="index" open="(" separator="," close=")">

            #{name}

        </foreach>

</select>

确实挺别扭的,而且注解里还不能用,只能被动适应了。

END

posted @ 2021-12-08 21:38  逆火狂飙  阅读(1052)  评论(0)    收藏  举报
生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东