Solucionado (ver solução)
Solucionado
(ver solução)
12
respostas

Erro Overflow numérico ao executar a aplicação

Olá pessoal, estou tentando criar uma aplicação com spring boot, spring web, spring dada jpa e spring react utilizando o banco Oracle 11g que é disponibilizado na empresa, porém ao subir o projeto é gerado o erro** Overflow numérico**. Apontei o datasource para um banco oracle 12c e nao tive este problema, porém o ambiente que tenho disponivel tanto para dev, ho e prd é voltado para o banco 11g, qual versão do Spring Data JPA eu poderia estar utilizando para solucionar este problema? Preciso usar uma versão mais antiga do Spring Boot tbm?

12 respostas

Oi Marcos,

Pode postar aqui a stacktrace da exception?

Qual versao do driver Oracle que voce esta utilizando?

oi Rodrigo segue o log do erro, como são muitos caracteres vou dividir em comentários: 2021-08-20 10:10:09.750 ERROR 29444 --- [ restartedMain] o.h.e.j.e.internal.JdbcEnvironmentImpl : Could not fetch the SequenceInformation from the database

java.sql.SQLException: Overflow Numérico at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:4162) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.NumberCommonAccessor.getLong(NumberCommonAccessor.java:643) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedStatement.getLong(GeneratedStatement.java:178) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedScrollableResultSet.getLong(GeneratedScrollableResultSet.java:286) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:626) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) ~[HikariCP-4.0.3.jar:na] at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.resultSetMinValue(SequenceInformationExtractorLegacyImpl.java:134) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:60) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.sequenceInformationList(JdbcEnvironmentImpl.java:403) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.(JdbcEnvironmentImpl.java:268) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:152) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:176) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1224) [hibernate-core-5.4.32.Final.jar:5.4.32.Final] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1255) [hibernate-core-5.4.32.Final.jar:5.4.32.Final]

Continuando o log de erro:

at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) [spring-orm-5.3.9.jar:5.3.9] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.3.9.jar:5.3.9] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) [spring-orm-5.3.9.jar:5.3.9] at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) [spring-orm-5.3.9.jar:5.3.9] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) [spring-beans-5.3.9.jar:5.3.9] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.9.jar:5.3.9] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.9.jar:5.3.9] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.9.jar:5.3.9] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.4.jar:2.5.4] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.4.jar:2.5.4] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.4.jar:2.5.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.4.jar:2.5.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.4.jar:2.5.4] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.4.jar:2.5.4] at br.com.cooxupe.apiplsqlcall.ApiplsqlcallApplication.main(ApiplsqlcallApplication.java:10) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_251] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_251] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_251] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.5.4.jar:2.5.4]

Segue o Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>br.com.cooxupe.apiplsqlcall</groupId>
    <artifactId>apiplsqlcall</artifactId>
    <version>1</version>
    <name>apiplsqlcall</name>
    <description>teste banco Oracle</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>

        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Marcos,

Ja vi esse problema no Orcale por conta do atributo ID das entidades estarem como Int ou Long.

Verifique suas entidades e altere o tipo do atributo id para BigInteger e veja se o problema para de ocorrer.

Rodrigo, realizei a alteração e o problema ocorre Entidade

@Entity
@Table(name="my_table")
@Data
public class Tabela {

    @Id
    @GeneratedValue( strategy=GenerationType.SEQUENCE)
    private BigInteger id;

   @Column(name="ds_teste")
   private String dsTeste;
   @Column(name="dt_criacao")
    private LocalDate dtCriacao;
   @Column(name="nm_usuario_criacao")
    private String nmUsuarioCriacao;

Tabela no banco o tipo Number no banco de dados deve ser alterado?

CREATE TABLE my_table (

    id                  NUMBER(15) ,
    ds_teste              VARCHAR2(4000),
    dt_criacao             DATE,
    nm_usuario_criacao     VARCHAR2(30),
    dt_alteracao           DATE,
    nm_usuario_alteracao   VARCHAR2(30)
);

parte da mensagem:

2021-08-20 14:51:22.649 ERROR 29388 --- [ restartedMain] o.h.e.j.e.internal.JdbcEnvironmentImpl : Could not fetch the SequenceInformation from the database

java.sql.SQLException: Overflow Numérico at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:4162) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.NumberCommonAccessor.getLong(NumberCommonAccessor.java:643) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedStatement.getLong(GeneratedStatement.java:178) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedScrollableResultSet.getLong(GeneratedScrollableResultSet.java:286) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:626) ~[ojdbc8-21.1.0.0.jar:21.1.0.0.0] at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) ~[HikariCP-4.0.3.jar:na] at `

estou usando estas configurações no arquivo properties alem do usuario e senha o url do banco.

spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1


# Show or not log for each sql query
spring.jpa.show-sql=true

# Naming strategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect

O campo id do banco pode ser NUMBER(15) quando declaro como BigInteger no Java?

Também estou enfrentando o mesmo problema e até o momento não consegui solucionar. Qualquer ajuda é bem vinda.

Insira aqui a descrição dessa imagem para ajudar na acessibilidade

Oi pessoal,

No Oracle precisa ter definido uma sequence no banco de dados para cada tabela e ela deve ser mapeada nas entidades. Talvez seja esse o problema.

Exemplo de como mapear:

@Entity
@Table(name = "clientes")
@Data
public class Cliente {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CLIENTE_SEQ")
    @SequenceGenerator(sequenceName = "cliente_seq", allocationSize = 1, name = "CLIENTE_SEQ")
    private BigInteger id;

}

Oi Rodrigo muito obrigado pelo retorno, tentei este procedimento porém o erro persistia, consegui resolver o problema utilizando o link abaixo.

https://coderoad.ru/60283784/Spring-boot-connection-oracle-%D0%B1%D0%B0%D0%B7%D0%B0-%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85

solução!

Boa Marcos!

Parece ser um problema relacionado com o Dialeto do banco de dados utilizado pelo Hibernate entao.