org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
【MyBatisSystemException 】Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ur" <K_ISOLATION>
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT DISTINCT u.id, u.username, u.nickname, u.dept_id, u.email, u.mobile FROM system_users u LEFT JOIN system_dept d ON u.dept_id = d.id LEFT JOIN system_user_role ur ON u.id = ur.user_id LEFT JOIN system_role r ON r.id = ur.role_id WHERE u.deleted = 0 ### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT DISTINCT u.id, u.username, u.nickname, u.dept_id, u.email, u.mobile FROM system_users u LEFT JOIN system_dept d ON u.dept_id = d.id LEFT JOIN system_user_role ur ON u.id = ur.user_id LEFT JOIN system_role r ON r.id = ur.role_id WHERE u.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.$Proxy139.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy193.selectAllocatedList(Unknown Source) ...... at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:39) at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserSingle(JsqlParserSupport.java:52) at com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor.beforeQuery(TenantLineInnerInterceptor.java:65) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:78) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy158.query(Unknown Source) at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:132) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy158.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) ... 184 common frames omitted Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ur" <K_ISOLATION> at line 11, column 36. Was expecting one of: ";" "ACTION" "ACTIVE" "ALGORITHM" "ARCHIVE" "ARRAY" "AS" "AT" "BYTE" "CASCADE" "CASE" "CAST" "CHANGE" "CHAR" "CHARACTER" "CHECKPOINT" "COLUMN" "COLUMNS" "COMMENT" "COMMIT" "CONNECT" "COSTS"
【问题】sql在mysql中能执行,但通过mybatisplus就报错
【原因】经过排查,竟然是mybatisplus执行sql的别名冲突!!!
开始通过报错还不相信,这个 ur 竟然在mybatisplus中运行不了 | ToT |
【解决】更换成别的别名
bug怎么这么多!