【问题标题】:Spring Boot - Couldn't get at the OracleSpatial Connection object from the PreparedStatementSpring Boot - 无法从 PreparedStatement 获取 OracleSpatial Connection 对象
【发布时间】:2018-10-05 08:59:52
【问题描述】:

我正在使用 Spring Boot 2.0.1、hibernate-spatial 5.2.17、Oracle DB 12c。 HikariCP 用于连接池和休眠方言为 OracleSpatial10gDialect。在查询中使用休眠空间函数时出现以下异常。

org.springframework.orm.jpa.JpaSystemException: java.lang.RuntimeException: 无法从 PreparedStatement 获取 OracleSpatial Connection 对象。嵌套异常是 org.hibernate.HibernateException: java.lang.RuntimeException: Couldn't get at the OracleSpatial Connection object from PreparedStatement。

我尝试了来自 Couldn't get at the OracleSpatial Connection object from the PreparedStatement 的建议。但面临同样的问题。

任何指向解决方案的指针都会有很大帮助。谢谢。

【问题讨论】:

    标签: hibernate spring-boot oracle-spatial


    【解决方案1】:

    来自休眠文档:https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html

    [ConnectionFinder 界面][1] [1]:https://i.stack.imgur.com/5by4Q.png

    我解决了这个问题:

    • 实现接口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);
         }
       }
      
    • 配置application.yml:

        spring:
          jpa:
            properties:
              hibernate:
                dialect: org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect
                spatial:
                  connection_finder: it.dedagroup.slim.data.domain.CustomConnectionFinder
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 2019-10-10
      • 1970-01-01
      • 2019-05-19
      • 2023-04-11
      • 2020-05-10
      • 2021-06-25
      相关资源
      最近更新 更多