1

レコードのリストを更新しようとしていますが、mybatis で次のエラーが発生しました。

 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'list' in 'class com.model.DataParameters'

私のmybatis xmlクエリは次のとおりです

<update id="deleteAssociatedEntityForParentEntity" parameterType="com.model.DataParameters">
    update dataTable set deleted = #{deleted}, syncTS = #{syncTS} where
    data_id in
    <foreach item="dataIds" index="index" collection="list"
        open="(" separator="," close=")">
        #{dataIds}
    </foreach>
    and aData_type = #{dataType};

</update>

DataParameter クラス getter setter がこのクラスで宣言されています。dataIds は私のリストです。

私のクエリで何か間違っているかどうか教えてください。リストが取り込まれていないのはなぜですか?他の方法はありますか?

4

2 に答える 2

0

クラスのリスト名を collection 属性に入れ、任意の名前を item 属性に入れ、以下で使用します

このコードを試してください:

<update id="deleteAssociatedEntityForParentEntity" parameterType="com.model.DataParameters">
    update dataTable set deleted = #{deleted}, syncTS = #{syncTS} where
    data_id in
    <foreach item="id" index="index" collection="dataIds"
        open="(" separator="," close=")">
        #{id}
    </foreach>
    and aData_type = #{dataType};

</update>
于 2014-12-15T11:12:16.037 に答える