Java Mybatis 甲骨文
我在 xml 文件中有以下 mybatis 语句
<update id="updateOfferIndex" parameterType="java.util.List">
<foreach collection="list" item="offer" index="index" separator=";" >
UPDATE offer set indx=#{offer.idx} WHERE id=#{offer.eId}
</foreach>
我遇到以下错误,有人可以帮忙吗?
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
### The error may involve com.dao.linear.upsell.LinearUpsellDao.updateOfferIndex-Inline
### The error occurred while setting parameters
### SQL: UPDATE offer set indx=? WHERE id=? ; UPDATE offer set indx=? WHERE id=?
### Cause: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
最佳答案
我通过以这种方式插入 BEGIN-END 语句来解决:
BEGIN
<foreach collection="list" item="offer" index="index" separator=";" >
UPDATE offer set indx=#{offer.idx} WHERE id=#{offer.eId}
</foreach>;
END;
我希望这能解决。
关于Java Mybatis 多条更新语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33372524/