ibatis执行多条sql?

发布于 2021-11-24 03:36:17 字数 2820 浏览 859 评论 7

ibatis怎么配置 执行多条sql

类似这个意思:

<delete  id="deleteRelatedDatas" parameterClass="java.lang.Long">
        delete from t_table_1 t1 where t1.user_id=#value#;
        delete from t_table_2 t2 where t2.user_id=#value#;
        delete from t_table_3 t3 where t3.user_id=#value#;
</delete>

错误:

{conn-100593} Preparing Statement:    delete from t_table_1 t1 where t1.user_id=?;   delete from t_table_2 t2 where t2.user_id=?;   delete from t_table_3 t3 where t3.user_id=?;  
Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/xxx/pojo/xml/Xxxx.xml.  
--- The error occurred while applying a parameter map.  
--- Check the com.xxxx.pojo.Xxxxx.deleteRelatedDatas-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1 where t1.user_id=99;   delete from t_table_2 t2 where t2.user_id=99;   delete' at line 1
org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/xxxx/pojo/xml/Xxxxx.xml.  
--- The error occurred while applying a parameter map.  
--- Check the com.xxxx.pojo.Xxxx.deleteRelatedDatas-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1 where t1.user_id=99;   delete from t_table_2 t2 where t2.user_id=99;   delete' at line 1
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
    at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

醉酒的小男人 2021-11-27 01:21:18

回复
那可能ibatis又做了什么手脚吧

后知后觉 2021-11-27 01:00:40

batch update 试试。

把回忆走一遍 2021-11-26 23:10:15

where col in(id1,id2,id3)

皇甫轩 2021-11-26 23:09:09

回复
报错发上来!

爱的那么颓废 2021-11-26 00:59:16

回复
直接发到问题里了,分号的错,好像不支持这么写,你也用的ibatis?

蓝颜夕 2021-11-25 09:55:16

回复
我用的是mybatis最新版,有区别吗?

檐上三寸雪 2021-11-25 04:17:04

回复
那个参数可以,应该是我代码的问题,谢了

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文