-
Notifications
You must be signed in to change notification settings - Fork 154
Description
确认
当前程序版本
1.5.4
问题描述
mybatis-plus版本3.5.14,mybatis-plus-join版本1.5.4。使用unionAll时报类型转换异常。
public Page getUserPageByName(Page page, String paramName) {
MPJLambdaWrapper wrapper = new MPJLambdaWrapper();
wrapper.selectAs(SysUser::getUserId, SmartSearchUserPageVO::getUserId)
.selectAs(SysUser::getUsername, SmartSearchUserPageVO::getUsername)
.selectAs(SysUser::getPhone, SmartSearchUserPageVO::getPhone)
.selectAs(SysUser::getNickname, SmartSearchUserPageVO::getNickname)
.selectAs(SysUser::getName, SmartSearchUserPageVO::getName)
.selectAs(SysUser::getType, SmartSearchUserPageVO::getType)
.selectAs("1", SmartSearchUserPageVO::getFavoriteStatus)
.unionAll(SysUser.class, w -> w.selectAs(SysUser::getUserId, SmartSearchUserPageVO::getUserId)
.selectAs(SysUser::getUsername, SmartSearchUserPageVO::getUsername)
.selectAs(SysUser::getPhone, SmartSearchUserPageVO::getPhone)
.selectAs(SysUser::getNickname, SmartSearchUserPageVO::getNickname)
.selectAs(SysUser::getName, SmartSearchUserPageVO::getName)
.selectAs(SysUser::getType, SmartSearchUserPageVO::getType)
.selectAs("0", SmartSearchUserPageVO::getFavoriteStatus));
return baseMapper.selectJoinPage(page, SmartSearchUserPageVO.class, wrapper);
}
详细堆栈日志
2025-12-26 16:38:03.330 ERROR 48160 --- [ XNIO-1 task-2] c.h.e.c.s.h.GlobalBizExceptionHandler : 全局异常信息 ex=
### Error querying database. Cause: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.ParenthesedSelect cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.ParenthesedSelect and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader 'app')
### Cause: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.ParenthesedSelect cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.ParenthesedSelect and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader 'app')
org.mybatis.spring.MyBatisSystemException:
### Error querying database. Cause: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.ParenthesedSelect cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.ParenthesedSelect and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader 'app')
### Cause: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.ParenthesedSelect cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.ParenthesedSelect and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader 'app')
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:101)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)
at jdk.proxy2/jdk.proxy2.$Proxy186.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:119)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:84)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:156)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:93)