0

我们使用 Weblogic、Hibernate 4.2.7、Hibernate Spatial 4.0 和 Oracle 作为数据库。

有时在执行保存操作时,我们观察到无法连接

您能建议我们为 Spatial 遗漏的任何配置吗?

    Stack Trace :
    Caused by: org.hibernate.spatial.helper.FinderException: Tried retrieving OracleConnection from weblogic.jdbc.wrapper.JTSConnection_weblogic_jdbc_wrapper_PooledConnection_oracle_jdbc_driver_LogicalConnection using method getConnectionCacheCallbackPrivObj, but received null.
    at org.hibernate.spatial.dialect.oracle.DefaultConnectionFinder.find(DefaultConnectionFinder.java:75)
    at org.hibernate.spatial.dialect.oracle.DefaultConnectionFinder.find(DefaultConnectionFinder.java:44)
    at org.hibernate.spatial.dialect.oracle.OracleJDBCTypeFactory.createStruct(OracleJDBCTypeFactory.java:119)
    ... 79 more
4

3 回答 3

0

Hibernate Spatial for Oracle DB 需要本地 oracle 连接(查看文档部分The ConnectionFinder Interface)。您必须调整 weblogic 配置或实施您自己的配置ConnectionFinder以向 Hib-Spa 提供 Oracle 连接。

例如,如果您使用的是使用 DBCP 连接轮询,则只需将accessToUnderlyingConnectionAllowed属性设置为true.

祝你好运!

于 2015-06-29T10:22:48.217 回答
0

如果您正在使用 Spring (Boot) JPA,请尝试

spring.jpa.properties.hibernate.spatial.connection_finder=yourpackage.CustomConnectionFinder

使用连接查找器:

public class CustomConnectionFinder implements ConnectionFinder {
    private static final Logger logger = LoggerFactory.getLogger(CustomConnectionFinder.class);

    @Override
    public Connection find(Connection connection) {
        try {
            return ((HikariProxyConnection) connection).unwrap(OracleConnection.class);
        } catch (SQLException e) {
            logger.error("CustomConnectionFinder: error={}", e.getMessage(), e);
        }
        return null;
    }
}
于 2021-07-07T09:18:55.533 回答
0

如果您使用的是使用 DBCP 连接轮询,您只需将accessToUnderlyingConnectionAllowed属性设置为true `@Bean public BasicDataSource dataSource() {

    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(oracleDriver);
    dataSource.setUrl(oracleUrl);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setInitialSize(initSize);
    dataSource.setMaxIdle(maxIdle);
    dataSource.setMaxActive(maxActive);
    dataSource.setMinIdle(minIdle);
    dataSource.setAccessToUnderlyingConnectionAllowed(true);
    return dataSource;
}

`

于 2017-06-27T14:06:02.070 回答