[英]Multiple statements in single mapper method in MyBatis
我有一個mapper方法來刪除表中的所有記錄。 但首先我需要從關聯的聯結表中刪除所有記錄。 這是我試過的:
@Delete("delete from COC_BLOCK_FIELD; delete from COC_BLOCK;")
void deleteBlocks();
這似乎是合理的,但MyBatis在處理我的mapper時拋出異常:
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. 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 'delete from COC_BLOCK' at line 1
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: delete from COC_BLOCK_FIELD; delete from COC_BLOCK;
### 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 'delete from COC_BLOCK' at line 1
我正在使用MyBatis 3.2.6,MySQL 5.5.35-1ubuntu1和MySQL Connector 5.1.26。
問題是我沒有在JDBC URL中設置標志allowMultiQueries=true
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.