【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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM