ibatis执行多条sql?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
回复
那可能ibatis又做了什么手脚吧
batch update 试试。
where col in(id1,id2,id3)
回复
报错发上来!
回复
直接发到问题里了,分号的错,好像不支持这么写,你也用的ibatis?
回复
我用的是mybatis最新版,有区别吗?
回复
那个参数可以,应该是我代码的问题,谢了