ClassCastException:保存实体时无法将 Long 转换为 Integer 类

问题描述 投票:0回答:1

最近越来越

java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')
    at java.base/java.util.stream.Collectors.lambda$summingInt$19(Collectors.java:681)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 

尝试使用 r2dbc 保存方法更新实体时,如下所示:

override suspend fun save(entity: Entity): Entity = r2dbc.save(entity).awaitSingle()

没有更多的逻辑,所以我猜想在尝试解析更新的实体时抛出了类转换异常,无法理解为什么会发生这种情况,

我用

spring boot version 2.7.9
org.postgresql:r2dbc-postgresql", version = "1.0.1.RELEASE

我的实体类具有

id
类型的
Long
,在我的数据库表中
id
bigint

任何帮助表示赞赏!

java postgresql spring-webflux project-reactor spring-data-r2dbc
1个回答
3
投票

尝试使用

0.9.2.RELEASE
版本的r2dbc驱动程序。

我在保存 1.0+ 版本和 Spring Boot 2.7 的实体时遇到了同样的问题。*

© www.soinside.com 2019 - 2024. All rights reserved.