为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:达梦8 1-2-84-21.10.21-149328-10032-SEC
【操作系统】:window11
【CPU】: x86
【问题描述】*:
以前使用 springboot 2.x +shardingsphere-jdbc 4.1.1 +jdk 1.8 升级 springboot 3.x +shardingsphere-jdbc 5.5.2 +jdk 17 后提示
后来在论坛找到一篇文章 https://zhuanlan.zhihu.com/p/1950129456057390686 后,根据文件的配置调整后,服务可以连接上数据库了,但是现在发现有很多基础的sql都不兼容,比如如下异常:
提示日志:Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement. Cause: org.apache.shardingsphere.infra.exception.dialect.exception.syntax.sql.DialectSQLParsingException: You have an error in your SQL syntax: select storage_space_size from jweb_user_space_allocation where
(
(target_id in (2004080259851790002) and target_type=1 and status=1)
)
order by upload_time desc limit 1, null
经过查看mybatis 源sql是这样写的 如下:
<select id="getUserSpaceByUserInfo" resultType="java.lang.Long">
select storage_space_size from jweb_user_space_allocation where status=1
and ((target_id=#{userId} and target_type=0)
<if test="depIds!=null and depIds!='' ">
or (target_id in (${depIds}) and target_type=1)
</if>
<if test="groupIds!=null and groupIds!='' ">
or (target_id in (${groupIds}) and target_type=2)
</if>
)
order by upload_time desc limit 1
</select>
注意:上面这样写,没有升级shardingsphere-jdbc之前是没有问题的,升级之后就不行了。
目前的情况经过测试,简单的select * from jweb_table 这种检查的查询是支持的,复杂一点的就不行了,比如 有limit 1、left join 等,都会不兼容。
麻烦各位大佬帮忙看看,谢谢
