1

I am using Spring Boot 2.0.1 , hibernate-spatial 5.2.17 , Oracle DB 12c. HikariCP For Connection pool and hibernate dialect as OracleSpatial10gDialect. I get the following exception when hibernate spatial functions are used in my query.

org.springframework.orm.jpa.JpaSystemException: java.lang.RuntimeException: Couldn't get at the OracleSpatial Connection object from the PreparedStatement.; nested exception is org.hibernate.HibernateException: java.lang.RuntimeException: Couldn't get at the OracleSpatial Connection object from the PreparedStatement.

I tried suggestions from here Couldn't get at the OracleSpatial Connection object from the PreparedStatement . But facing same issue.

Any pointers to the solution would be of great help. Thank you.

rahul
  • 21
  • 2

1 Answers1

1

From hibernate documentation: https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html

The ConnectionFinder interface

enter image description here

I solved the problem:

  • implementing the interface org.geolatte.geom.codec.db.oracle.ConnectionFinder;

    public class CustomConnectionFinder implements ConnectionFinder {
       @SneakyThrows
       @Override
       public Connection find(Connection connection) {
         return ((HikariProxyConnection) connection).unwrap(OracleConnection.class);
       }
     }
    
  • Configuring the application.yml:

    spring:
      jpa:
        properties:
          hibernate:
            dialect: org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
            spatial:
              connection_finder: it.dedagroup.slim.data.domain.CustomConnectionFinder
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159