baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.35k stars 4.31k forks source link

pagehelper和mybatisplus所引用的jsqlparser版本冲突问题 #5675

Closed xhc-code closed 1 year ago

xhc-code commented 1 year ago

当前使用版本(必填,否则不予处理)

<groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.5.2</version>

使用的jsqlparser版本是4.4


<dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
  <version>5.3.2</version>
        </dependency>

使用的jsqlparser版本是4.5

该问题是如何引起的?(确定最新版也有问题再提!!!)

将jsqlparser引入4.4,会导致查询select报错,但是sql是正确的,可以正常执行的。

nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status from sys_user u left join sys_dept d on u.dept_id = d.dept_id left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id where u.user_name = ? and u.del_flag = '0' ### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status from sys_user u left join sys_dept d on u.dept_id = d.dept_id left join sys_user_role ur on u.user_id = ur.user_id left join sys_role r on r.role_id = ur.role_id where u.user_name = ? and u.del_flag = '0'

将jsqlparser引入4.5,会导致保存insert报错,没有打印出sql,但是sql是mybatisplus自动生成的,应该不会有问题。

nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.lang.ClassCastException: net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect ### The error may exist in com/mapper/WarehouseMapper.java (best guess) ### The error may involve com.mapper.HelloMapper.insert ### The error occurred while executing an update ### Cause: java.lang.ClassCastException: net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect

重现步骤(如果有就写完整)

就很神奇和极端,无论取低版本还是高版本都不行。

miemieYaho commented 1 year ago

https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-core/3.5.3.2

xhc-code commented 1 year ago

你的意思是让我升级?升级到4.6不行啊,因为pagehelper的最新版本引用的是4.5版本的jsqlparser。不过倒是还没尝试。

app2smile commented 1 year ago

升级试试. 我现在用4.6的jsqlparser PageHelper可以正常用

xhc-code commented 1 year ago

升级试试.我现在用4.6的jsqlparser PageHelper可以正常用

可以告诉下你的mybatisplus和pagehelper的版本信息吗?我现在是将jsqlparser降到4.3的版本,可以正常使用,目前倒是没有发现其他问题。

app2smile commented 1 year ago

spring boot 2.6.14 mybatis starter 2.3.1 mybatis-plus 3.5.3.2 pageHelper starter 1.4.7 排除了pageHelper中的jsqlparser

xhc-code commented 1 year ago

spring boot 2.6.14 mybatis starter 2.3.1 mybatis-plus 3.5.3.2 pageHelper starter 1.4.7 排除了pageHelper中的jsqlparser

好的,谢谢。