当前使用版本(必填,否则不予处理)
3.4.3.4
该问题是如何引起的?(确定最新版也有问题再提!!!)
selectPage
重现步骤(如果有就写完整)
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
return interceptor;
}
}
报错信息
Creating a new SqlSession SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d02ddfc] was not registered for synchronization because synchronization is not active JDBC Connection [org.postgresql.jdbc.PgConnection@4e9f43] will not be managed by Spring ==> Preparing: SELECT COUNT() AS total FROM sql_audit_rule ==> Parameters: Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6d02ddfc] 2021-12-29 15:50:03.049 ERROR 11080 --- [io-65432-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:
Error querying database. Cause: org.postgresql.util.PSQLException: ERROR: count(*) must be used to call a parameterless aggregate function
位置:8
The error may exist in rpm/sql/audit/rule/mapper/SqlAuditRuleMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT COUNT() AS total FROM sql_audit_rule
Cause: org.postgresql.util.PSQLException: ERROR: count(*) must be used to call a parameterless aggregate function
位置:8 ; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: count(*) must be used to call a parameterless aggregate function 位置:8] with root cause
org.postgresql.util.PSQLException: ERROR: count(*) must be used to call a parameterless aggregate function
Comment From: ZhouXunYou
生成的count语句是 SELECT COUNT() AS total FROM sql_audit_rule
Comment From: qmdx
你测试下 3.5.0-SNAPSHOT 使用方式 https://baomidou.com/pages/bab2db/
Comment From: ZhouXunYou
找到问题了。由于业务关系,我使用了 jsqlparser 4.3 版本,而mybatis-plus依赖的是 4.2 版本,一个小版本的差异,怎么会造成这样的问题呢 @qmdx
Comment From: qmdx
找到问题了。由于业务关系,我使用了 jsqlparser 4.3 版本,而mybatis-plus依赖的是 4.2 版本,一个小版本的差异,怎么会造成这样的问题呢 @qmdx
jsqlparser 本身问题,新版本做了兼容,关注发版
Comment From: ydc201314
我引用的是3.4.1 版本 突然报这个错了
Comment From: ydc201314
Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM tb_physical_datasource' at line 1
The error may exist in com/glodon/city/bcp/support/core/mapper/PhysicalDatasourceMapper.java (best guess)
The error may involve defaultParameterMap
The error occurred while setting parameters
SQL: SELECT COUNT() FROM tb_physical_datasource
Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM tb_physical_datasource' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM tb_physical_datasource' at line 1