JPA Hibernate + UCP Oracle. Query executed from save method does not use table index

I am using the CRUDRepository interface to use the save method in another class where the repository is injected.

This method does insert and select to retrieve this object inserted from the database, I mean.

The query performed is pretty simple:

select auditoriab0_.adb_seqitm as adb_seqitm1_1_0_,
 auditoriab0_.adb_codprv as adb_codprv2_1_0_, auditoriab0_.adb_ideses as adb_ideses3_1_0_,
 auditoriab0_.adb_locata as adb_locata4_1_0_, auditoriab0_.adb_rqores as adb_rqores5_1_0_,
 auditoriab0_.adb_rstime as adb_rstime6_1_0_, auditoriab0_.adb_subprv as adb_subprv7_1_0_,
 auditoriab0_.adb_swierr as adb_swierr8_1_0_, auditoriab0_.adb_tiptrz as adb_tiptrz9_1_0_,
 auditoriab0_.adb_ubitrz as adb_ubitrz10_1_0_, auditoriab0_.adb_xmltxt as adb_xmltxt11_1_0_
 from nwt00.auditoria_bus_gsi auditoriab0_ where auditoriab0_.adb_seqitm=:p1

      

Where the column adb_seqitm

has and an index on it (this is the primary key of the table).

If this query is executed in SQLDeveloper, for example, the explain plan is correct (access by rowid).

However, if this request is executed by hibernation, the result is a full scan.

Could you please help me with this problem? I will be grateful because I have not seen a real solution on the internet for this particular problem.

Thanks in advance.

This behavior occurs with the ucp pool (pool pool). My database bean config is as follows (variables are set by application.properties file):

UniversalConnectionPoolManager mgr;
        try {
            mgr = UniversalConnectionPoolManagerImpl. getUniversalConnectionPoolManager();
            mgr.destroyConnectionPool("hotels");
        } catch (UniversalConnectionPoolException e) {
        }
        PoolDataSourceImpl poolDataSource = (PoolDataSourceImpl) PoolDataSourceFactory.getPoolDataSource();
        poolDataSource.setUser(userName);
        poolDataSource.setPassword(passWord);
        poolDataSource.setURL(url);
        poolDataSource.setConnectionFactoryClassName(driver);
        poolDataSource.setConnectionPoolName("hotels");
        poolDataSource.setInitialPoolSize(initialNumConnections);
        poolDataSource.setMinPoolSize(minNumConnections);
        poolDataSource.setMaxPoolSize(maxNumConnections);
        poolDataSource.setMaxConnectionReuseTime(reconnectTime);
        poolDataSource.setMaxConnectionReuseCount(maxReconnectCount);
        poolDataSource.setTimeToLiveConnectionTimeout(timeToLive);
        poolDataSource.setConnectionWaitTimeout(connectWaitTimeOut);
        poolDataSource.setValidateConnectionOnBorrow(true);
        poolDataSource.setInactiveConnectionTimeout(inactiveConnectionTimeOut);
        Properties properties = new Properties();
        properties.put("v$session.program", "xxxx");
        properties.put("defaultNChar", "false");
        poolDataSource.setConnectionProperties(properties );

      

I am using Spring Boot + Spring Data JPA. These are my dependencies of my pom.xml:

    <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-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.4.0</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ucp</artifactId>
        <version>11.2.0.4.0</version>
    </dependency>

      

+3


source to share


1 answer


@krokodilko As you expected, the error was between the database type and the java type. In DDBB, this field is a string (varchar2 (15)). In Java, this field is rendered as long type. I think hibernate or database is doing a conversion that breaks the index. I changed the java type to String and the request works successfully. Explain the plan correctly.



0


source







All Articles