使用mybatis批量更新时,报以下错误。反复检查过mysql语句没有任何问题。而且本地可以正常执行,生产环境却报错。起初怀疑是数据表,把生产环境表导入本地测试后依然没有问题。数据表没问题就定位到数据库,先检查本地数据库链接与生产环境比对,发现测试环境数据库链接缺失allowMultiQueries=true,要想执行批量查询,需要将该字段设为true
错误提示:
### The error may exist in URL [jar:file:/www/java_test/ruoyi-admin-test.jar!/BOOT-INF/lib/bzw-customer-4.7.8.jar!/mapper/customer/MemberMapper.xml]
### The error may involve com.ruoyi.customer.mapper.MemberMapper.batchMemberCompany-Inline
### The error occurred while setting parameters
### SQL: UPDATE member SET company_id =?, company_name=?,company_type=? WHERE id= ? ; UPDATE member SET company_id =?, company_name=?,company_type=? WHERE id= ?
### Cause: java.sql.SQLSyntaxErrorException: 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 'UPDATE member SET company_id =18,
解决方案:
allowMultiQueries=true