为什么mysql int(10)无符号列to row.getlong在jasync-sql中抛出异常



int(10)mySQL中未签名的限制为4B ,与行一起使用时,它会引发以下错误:

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

为什么不可能转换?

类型INT(10) UNSIGNED的大小(4个字节)和未签名:mysql

中的int(10)的最大大小是多少

但是,Java没有这种类型(即最大值大于最大Java Int)。另一方面,从MySQL返回的类型是INT所定义的:https://dev.mysql.com/doc/refman/8.0/en/integer-types.html,没有有关无签名的其他信息。在这种情况下,JASYNC-SQL将其转换为常规INT类型。更多详细信息在这里:https://github.com/jasync-sql/jasync-sql/issues/102

作为这种情况下的解决方法,可以像这里建议的那样进行扩大的转换:将签名整数转换为无签名长的最佳方法?

相关内容

  • 没有找到相关文章

最新更新