注册

spring-boot3.2.12+shardingsphere-jdbc 5.5.2适配达梦提示方言不兼容问题,急急急

Linkapp赖猷安 2025/12/15 67 0

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【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 后提示
b62c61571ad9b7f0f09f5e44bfbed7d9.png

后来在论坛找到一篇文章 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 等,都会不兼容。
麻烦各位大佬帮忙看看,谢谢

回答 0
暂无回答
扫一扫
联系客服