异常叙述:
Error querying database. 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 ‘)’ at line 1
The error may exist in com/shiku/mapper/BmsTagMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT id,name,topic_count FROM bms_tag WHERE id IN ( )
原因分析:
这里我使用了(com.baomidou.mybatisplus.extension.service.IService.listByIds)listByIds()方法,当参数传入为空时则触发此处异常
解决方法:
在使用这个方法前判断一下传入的参数是否为空,不为空时则调用。此处我并没有硬性要求需要传入不为空的参数。
后续有更好的解决办法再做修改。
本文介绍了在使用 MyBatis Plus 的 `listByIds` 方法时遇到的 SQL 语法错误,该错误发生在查询数据库时因参数为空导致。通过分析错误日志,确定问题可能源于在调用此方法时未对参数进行非空检查。为避免此类异常,建议在调用 `listByIds` 前先判断传入参数是否为空,确保参数不为空后再执行查询操作。这提供了一个临时解决方案,未来可以考虑优化代码结构以提高健壮性。
555

被折叠的 条评论
为什么被折叠?



