项目场景:
提示:这里简述项目相关背景:
Java+MyBatis项目中
问题描述
提示:
查询sql总条数时报错,显示无法查询:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql :
SELECT COUNT(1) FROM (SELECT id,coupon_code,name,icon_url,type,status,price,term_time,term_type,explain,remarks_info,create_time,update_time,delete_time FROM coupon
WHERE delete_time IS NULL) TOTAL
### The error may exist in io/github/talelin/latticy/mapper/CouponMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: Method queryTotal execution error of sql :
SELECT COUNT(1) FROM (SELECT id,coupon_code,name,icon_url,type,status,price,term_time,term_type,explain,remarks_info,create_time,update_time,delete_time FROM coupon
WHERE delete_time IS NULL) TOTAL
原因分析:
提示:问题的分析:
原因之一:sql表中有些关键字无法使用,可能重名
解决方案:
这里是字段**explain**为关键字,重新命名字段即可,这里我是改为explains,查询数据就正常,这个主要是日志不会报那个字段异常,只会显示这个实体表无法查询等,这是比较麻烦的地方,不知道关键词字段的只能一个个排除咯