You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "TaoPanfeng (via GitHub)" <gi...@apache.org> on 2025/09/09 07:07:08 UTC
[I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
TaoPanfeng opened a new issue, #36506:
URL: https://github.com/apache/shardingsphere/issues/36506
## Bug Report
<img width="1901" height="816" alt="Image" src="https://github.com/user-attachments/assets/89ff96bf-3845-4cca-8474-0db238c7ee45" />
When cooperating with Mybatis Plus pagination, there will be query errors.
(在配合 Mybatis Plus 分页时, 会查询错误, )
### Which version of ShardingSphere did you use?
shading-jdbc 5.5.2
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-bom</artifactId>
<version>3.5.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- ==================================== shardingsphere-jdbc ==================================== -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>5.5.2</version>
</dependency>
<!-- ==================================== jdbc ==================================== -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-jsqlparser</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
When performing pagination, do not report an error and SQL can obtain the parameters normally
(在进行分页的时候,不要报错,SQL 可以正常获取到参数)
### Actual behavior
as indicated above
(如上图)
### Reason analyze (If you can)
I placed the following class on my local machine and modified one line of code. It works normally. I don't know if there will be any other problems because of this.
I only use sharding-jdbc read-write separation
(我把下面这个类,放在我本地,修改了一行代码,是正常工作的,我不知道会不会因此有其他的问题。
我仅仅使用 sharding-jdbc 读写分离)
<img width="2527" height="1089" alt="Image" src="https://github.com/user-attachments/assets/405e9b2d-42dd-4173-8bf0-a7c240fe8d48" />
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
The following execution will report an error when parameters are passed in, but there will be no problem if no parameters are passed in.
(下面的执行,在传入参数时,会报错,不传入参数,则没问题。)
```
IPage<StudentEntity> testPage(IPage<StudentEntity> page, String name);
<select id="testPage" resultType="com.taopanfeng.shardingsphere.entity.StudentEntity">
with tmp as (
select * from student
<if test="name !=null and name != ''">
where name like concat('%', #{name}, '%')
</if>
)
select * from tmp
</select>
@Test
void 分页测试() {
// 不会报错
try {
IPage<StudentEntity> page = studentDao.testPage(PageDTO.of(1, 10), null);
System.out.println("========= 成功 1");
} catch (Exception e) {
System.err.println("========= 失败 1");
}
// 会报错
// Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
// at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext.getValue(PaginationContext.java:61)
// at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext.<init>(PaginationContext.java:52)
// at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine.LimitPaginationContextEngine.createPaginationContext(LimitPaginationContextEngine.java:38)
// at org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine.PaginationContextEngine.createPaginationContext(PaginationContextEngine.java:62)
// at org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext.setUpParameters(SelectStatementContext.java:422)
// at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createQueryContext(ShardingSpherePreparedStatement.java:274)
// at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:243)
try {
IPage<StudentEntity> page = studentDao.testPage(PageDTO.of(1, 10), "大牛");
System.out.println("========= 成功 2");
} catch (Exception e) {
System.err.println("========= 失败 2");
e.printStackTrace();
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "TaoPanfeng (via GitHub)" <gi...@apache.org>.
TaoPanfeng commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3269767770
> The issue involves other third-party dependencies, but our focus is solely on ShardingSphere itself. Since ShardingSphere implements the JDBC interface, standard applications should be functional. We wish to allocate more effort towards enhancing the current version, and therefore will no longer handle such issues. Please read the documentation or provide more effective information when submitting an issue.
I understand what you mean. Thank you for your reply.
(我明白了您的意思,感谢您的回复 。)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3269670406
The issue involves other third-party dependencies, but our focus is solely on ShardingSphere itself. Since ShardingSphere implements the JDBC interface, standard applications should be functional. We wish to allocate more effort towards enhancing the current version, and therefore will no longer handle such issues. Please read the documentation or provide more effective information when submitting an issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "TaoPanfeng (via GitHub)" <gi...@apache.org>.
TaoPanfeng commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3748573440
> 请问是如何解决的呢?
I have already answered another friend above. Reference link:
我在上面已经回答了另外一个小伙伴,参考链接:
https://github.com/apache/shardingsphere/issues/36506#issuecomment-3748567105
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "1191681612 (via GitHub)" <gi...@apache.org>.
1191681612 commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3748542776
有解决方案吗?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "TaoPanfeng (via GitHub)" <gi...@apache.org>.
TaoPanfeng commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3748567105
> 有解决方案吗?
Brother, there is a solution above. Refer to "Reason analyze (If you can)" above.
I have provided picture examples. Copy that class to your local device, create a new package with the same name, and then modify which line.
兄弟,上面有解决方案,参考上面的 “Reason analyze (If you can)”,
我给出了图片示例。(把那个类复制到本地,新建一个同名的包,然后把哪一行给改了,)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3300612390
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "catNineCool (via GitHub)" <gi...@apache.org>.
catNineCool commented on issue #36506:
URL: https://github.com/apache/shardingsphere/issues/36506#issuecomment-3341422676
> > 该问题涉及其他第三方依赖项,但我们的重点仅放在 ShardingSphere 本身。由于 ShardingSphere 实现了 JDBC 接口,因此标准应用程序应该能够正常运行。我们希望将更多精力投入到当前版本的优化上,因此将不再处理此类问题。请阅读文档或在提交问题时提供更有效的信息。
>
> 我明白你的意思。感谢你的回复。 (我明白您的意思,感谢您的回复。)
请问是如何解决的呢?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #36506: shardingsphere 5.5.2 Page :ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer
URL: https://github.com/apache/shardingsphere/issues/36506
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org