Closed t375152973 closed 7 months ago
我基本遇到的动态sql,生成的sql有大量\n\n的时候,JSqlParser就解析失败了,不知道mp如何解决,能压缩一下sql最好了
这样解决了
这样解决了
已经尝试过了,已经将SQL转换成如下样式还是无法正常执行。
SELECT b.*,GROUP_CONCAT(g.groupName
) AS groupNames FROM table1
b LEFT JOIN table2
m ON m.contactId
=b.id
LEFT JOIN table3
g ON g.id
= m.groupId
and g.center_id = ? WHERE b.isDelete
!= '1' and b.center_id = ? GROUP BY b.id
ORDER BY LENGTH(b.name
) ASC, CONVERT(b.name
, SIGNED) ASC, CONVERT(b.name
USING GBK), b.crewType
DESC
你看你报什么错,我那样是解决JSqlParser多个换行符解析报错问题,用正则删除多个换行保留一个换行,还有就是JSqlParser提供了一个在线解析sql的工具,你可以把原始sql贴进去,可以校验是否通过
你别压缩sql,就删除多个换行,保留一个
我基本遇到的动态sql,生成的sql有大量\n\n的时候,JSqlParser就解析失败了,不知道mp如何解决,能压缩一下sql最好了
goup by语句加条件的话应该用having而不能先where再group by
这样解决了
@baklpc 请教一下这个会不会把数据里的空行给替换了?比如:
update shop_info set title=?,
content='abc
def'
where id=?
当前使用版本
该问题是如何引起的?
复杂SQL解析失败,会出现错误。将jsqlparser升级到4.6版本仍然无法解决。 后与jsqlparser贡献者进行交流,知晓jsqlparser-4.7-SNAPSHOT版本能解决此问题,但更新后发现,分页拦截器内使用的SelectExpressionItem在4.7版本中已去除,因此,与mybatis-plus版本不兼容。故提出此问题,看是否有解决方案。 复杂SQL如下: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable2
m ON m.contactId
=b.id
LEFT JOINtable3
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1' GROUP BY b.id
ORDER BY LENGTH(b.name
) ASC, CONVERT(b.name
, SIGNED) ASC, CONVERT(b.name
USING GBK), b.crewType
DESC重现步骤(如果有就写完整)
1、mybatis-plus配置多租户拦截器实现多租户模式 2、xml编写上述SQL 3、使用租户拦截器、分页拦截器和乐观锁拦截器进行SQL拦截,拼写租户ID和分页信息 4、springboot容器启动调用报错
报错信息
[ERROR][2023-07-19 14:15:58:928] [szwa-business,10931121eb3d4cfd,10931121eb3d4cfd,] [http-nio-9192-exec-1-com.hrx.szwa.common.aspect.RestControllerAspect--124 line] - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Caused by: org.apache.ibatis.exceptions.PersistenceException: Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: SELECT b.*,GROUP_CONCAT(g.
groupName
) AS groupNames FROMtable1
b LEFT JOINtable1_map
m ON m.contactId
=b.id
LEFT JOINtable1_group
g ON g.id
= m.groupId
WHERE b.isDelete
!= '1'Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," "," at line 11, column 38.
Was expecting one of:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," "," at line 11, column 38.
Was expecting one of: