MybatisPlusException: Error: Method queryTotal execution error of sql
MybatisPlus查询报错
nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql
本地debug分析,e.printStackTrace();,打印堆栈信息
Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'h.wbr_id' in 'on clause'
问题解决
JOIN app_task H on T.id = h.wbr_id and H.staff_id = #{appTaskVO.staffId} AND H.state = 0
总结一下
mybatis不支持数据库表的别名的大小写别名适应。
Parameter index out of range
MybatisPlus查询报错
nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql
打印堆栈信息
Caused by: java.sql.SQLException: Parameter index out of range (4 > number of parameters, which is 3).
问题解决
对应的xml里面的sql语句包含注释信息,实际上只有3个参数,但是mybatis认为是4个参数,导致设置第4个参数报错,去除注释。
# JOIN app_task H on T.id = h.wbr_id and H.staff_id = #{appTaskVO.staffId} AND H.state = 0
总结一下
在mybatis对应的xml文件中,不要使用注释。
文章来源
发表评论