如何在Mybatis中将属性值绑定到集合?

时间:2017-05-15 10:41:08

标签: java mybatis

我有一个名为addCollectionToAndConditionWhenNotEmpty的自定义SQL作为Follows

<sql id="addCollectionToAndConditionWhenNotEmpty">
    <if test="collections != null and collections.isEmpty()">
        AND <if test="andNot = true">NOT</if> ${field}
        IN <foreach item="item" collection="collections" open="(" separator="," close=")">#{item}</foreach>
    </if>
</sql>

所以,我想要那个。

<include refid="addCollectionToAndConditionWhenNotEmpty">
    <property name="field" value="TABLE.column"/>
    <property name="collections" value="data.idList"/>
</include>

但是,会发生这样的错误。

nested exception is org.apache.ibatis.binding.BindingException: Parameter 'collections' not found. Available parameters are [param1, option]"

如何在Mybatis中将属性的值绑定到集合?

(+)如果像这样使用它,它将被执行,但我不想要它。

<bind name="collections" value="params.idList"/>
<include refid="addCollectionToAndConditionWhenNotEmpty">
    <property name="field" value="CNTT.cntt_no"/>
    <property name="collections" value="collections"/>
</include>

0 个答案:

没有答案