MyBatis / Ibatis错误:元素类型“update”的内容必须匹配

时间:2014-10-30 11:59:34

标签: java spring mybatis ibatis

我们更新了几行,在更新行之后,我们想要返回受影响的行数。我们编写了如下的xml文件

<update id="update" parameterClass="com.test.Delete">
        update entity_association set deleted = 1, syncTS = #syncTS# where
        assoc_entity_row_id in
        <iterate property="parentIds" open="(" close=")" conjunction=",">
            #parentIds[]#
        </iterate>
        and assoc_entity_type = #parentType#;
        <selectKey resultClass="int">
            select row_count()
        </selectKey>
    </update>

对于返回受影响的行数,当我们添加selectKey标记时,我们会收到错误"The content of element type "update" must match "(include|dynamic|iterate|isParameterPresent|isNotParameterPresent|isEmpty|isNotEmpty|isNotNull|isNull|isNotEqual|isEqual| isGreaterThan|isGreaterEqual|isLessThan|isLessEqual|isPropertyAvailable|isNotPropertyAvailable)"

有没有更好的方法来实现这个? selectKey标记适用于插入。

2 个答案:

答案 0 :(得分:0)

我认为dtd模式验证器会导致此错误。根据您的版本mybatis / ibatis,您可以使用不同的dtd模式。请在映射器名称空间中的模式规则中检查它=我使用dtd schema并使用foreach更新并选择关键字工作正常。

答案 1 :(得分:0)

找到一个让这个工作的黑客。我们在标签内附上更新查询并返回被触摸的行数。

相关问题