在mysql中,INT(10) unsigned最大限制为4b+,当与row的getLong一起使用时,会抛出以下错误:
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
at com.github.jasync.sql.db.RowData$DefaultImpls.getLong(RowData.kt:48) ~[jasync-common-0.9.23.jar:?]
at com.github.jasync.sql.db.general.ArrayRowData.getLong(ArrayRowData.kt:5) ~[jasync-common-0.9.23.jar:?]
at com.richdevt.hthookserver.repository.ProjectRepository.findProjectEnvironment(ProjectRepository.kt:29) ~[classes/:?]
at com.richdevt.hthookserver.repository.ProjectRepository$findProjectEnvironment$3.invokeSuspend(ProjectRepository.kt) ~[classes/:?]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32) [kotlin-stdlib-1.3.21.jar:1.3.21-release-158 (1.3.21)]
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233) [kotlinx-coroutines-core-1.1.1.jar:?]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163) [netty-common-4.1.33.Final.jar:4.1.33.Final]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) [netty-common-4.1.33.Final.jar:4.1.33.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.33.Final.jar:4.1.33.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-common-4.1.33.Final.jar:4.1.33.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.33.Final.jar:4.1.33.Final]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152为什么转换不可能?
发布于 2019-03-14 18:05:01
类型INT(10) UNSIGNED的大小为int (4字节)且无符号:What is the maximum size of int(10) in Mysql
然而,Java没有这样的类型(即最大值大于最大Java int)。另一方面,从MySQL返回的类型是INT,定义如下:https://dev.mysql.com/doc/refman/8.0/en/integer-types.html,没有关于unsigned的额外信息。在这种情况下,jasync-sql会将其转换为常规的Int类型。更多细节在这里:https://github.com/jasync-sql/jasync-sql/issues/102
作为这种情况的一种解决方法,可以像这里建议的那样进行扩大转换:Best way to convert a signed integer to an unsigned long?
https://stackoverflow.com/questions/55159687
复制相似问题