【MyBatisSystemException 异常】net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException:.....
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," ","
at line 1, column 164.
Was expecting one of:
"&"
"::"
";"
"<<"
">>"
"ACTION"
............................................................................
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT id,parent_id,`code`,user_id,`type`,source,title,content,end_time,finish_time,contact_id,sid,business_key,urgency,`status`,remind,reminder_show,reminder_time,keep,keep_check,keep_fre,keep_fre_rule,keep_weeks,keep_months,keep_start_date,keep_end_date,tenant_id,create_time,update_time,creator,updater,deleted FROM crm_task WHERE id=? AND deleted=0 ### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT id,parent_id,`code`,user_id,`type`,source,title,content,end_time,finish_time,contact_id,sid,business_key,urgency,`status`,remind,reminder_show,reminder_time,keep,keep_check,keep_fre,keep_fre_rule,keep_weeks,keep_months,keep_start_date,keep_end_date,tenant_id,create_time,update_time,creator,updater,deleted FROM crm_task WHERE id=? AND deleted=0 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy151.selectOne(Unknown Source) org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) ... 176 common frames omitted Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," "," at line 1, column 164. Was expecting one of: "&" "::" ";" "<<" ">>" "ACTION" "ACTIVE" "ALGORITHM" "ARCHIVE"
【问题】执行查询接口第一次请求失败,第二次成功问题。
【原因】经过一步步排查,终于找到bug原因了,竟然是mysql关键词冲突原因!!!
实体类DO里面使用了mysql的关键词,造成了解析错误原因。
【解决】解决方法,在属性字段上添加 @TableField 注解
@TableField("`keep`") private Boolean keep;