我有一个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。
答案 0 :(得分:9)
问题是我没有在JDBC URL中设置标志allowMultiQueries=true
。