暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

1217.java 报Could not fetch the SequenceInformation

原创 张鹏 2022-09-28
1674

1217.java 报Could not fetch the SequenceInformation

ERROR [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl|[STANDBY] ExecuteThread: ‘5’ for queue: ‘weblogic.kernel.Default (self-tuning)’]
Could not fetch the SequenceInformation from the database
java.sql.SQLException: Numeric Overflow
at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:4136)
at oracle.jdbc.driver.NumberCommonAccessor.getLong(NumberCommonAccessor.java:634)
at oracle.jdbc.driver.GeneratedStatement.getLong(GeneratedStatement.java:206)
at oracle.jdbc.driver.GeneratedScrollableResultSet.getLong(GeneratedScrollableResultSet.java:259)
at oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:558)
at
at

The Long.MAX_VALUE is equal to 9223372036854775807, therefore I got the numeric overflow exception.
sequence的minvalue,maxvalue超过这个数值导致越界

解决方案:
1.java端更改
I solved the problem as follows. Created an extension for Oracle12cDialect. Limited the maximum/minimum value of columns to SQL
package ru.mvawork.hibernate;

import org.hibernate.dialect.Oracle12cDialect;

@SuppressWarnings(“unused”)
public class CustomOracleDialect extends Oracle12cDialect {

@Override
public String getQuerySequencesString() {
    return "select SEQUENCE_OWNER, SEQUENCE_NAME, greatest(MIN_VALUE,         -9223372036854775807) MIN_VALUE,\n"+
            "Least(MAX_VALUE, 9223372036854775808) MAX_VALUE, INCREMENT_BY,     CYCLE_FLAG, ORDER_FLAG, CACHE_SIZE,\n"+
            "Least(greatest(LAST_NUMBER, -9223372036854775807), 9223372036854775808) LAST_NUMBER,\n"+
            "PARTITION_COUNT, SESSION_FLAG, KEEP_VALUE\n"+
            "from all_sequences";
}

}
In the application.properties file referred to a dialect implementation
spring.jpa.properties.hibernate.dialect=ru.mvawork.hibernate.CustomOracleDialect
You can recreate sequences by limiting the minimum and maximum values. In my case, I can 't do it. The primary keys that I use have the dimension Number (12), which falls within the range limit from -9223372036854775807 to 9223372036854775808 with a large margin

2.或者数据库端更改

SQL> CREATE SEQUENCE SEQ_TEST START WITH 1 INCREMENT BY 1 NOCYCLE;
SQL> select MIN_VALUE, MAX_VALUE, INCREMENT_BY
from USER_SEQUENCES
where SEQUENCE_NAME = ‘SEQ_TEST’;

MIN_VALUE MAX_VALUE INCREMENT_BY


1 9999999999999999999999999999 1

alter sequence test_sequence minvalue -9223372036854775806;
alter sequence test_sequence maxvalue 9223372036854775807;

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论