本文介绍了实现方法 org.postgresql.jdbc4.Jdbc4Connection.getSchema()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,在休眠中没有实现 getSchema().我应该使用哪些依赖项?第一次测试通过,但错误仍然存​​在.第二次测试总是失败.如果我删除架构中的表,测试再次通过.下一个文本或现有表失败.

I have problem, there isn't realisation of getSchema() in hibernate. What dependencies should I use? First test pass, but error stay. The second test always fail. If I delete tables in schema, test pass again. And next text eith existing table fail.

ApplicationConfig.xml

ApplicationConfig.xml

<?xml version="1.0" encoding="UTF-8"?>

<jpa:repositories base-package="com.shilko.ru.wither.database"/>

<bean id="psqlDataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:2222/postgres" />
    <property name="username" value="postgres" />
    <property name="password" value="" />
    <property name="connectionProperties">
        <props>
            <prop key="socketTimeout">10</prop>
        </props>
    </property>
</bean>

<bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="psqlDataSource" />
    <property name="packagesToScan" value="com.shilko.ru.wither.database" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
    </property>

    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL95Dialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

错误日志

    19:23:06.113 [main] DEBUG org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver - Unable to use Java 1.7 Connection#getSchema : An error occurred trying to resolve the connection default schema resolver: Method org.postgresql.jdbc4.Jdbc4Connection.getSchema() is not yet implemented.
19:23:06.117 [main] DEBUG org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl - Unable to resolve connection default schema
org.hibernate.HibernateException: Use of DefaultSchemaNameResolver requires Dialect to provide the proper SQL statement/command but provided Dialect [org.hibernate.dialect.PostgreSQL95Dialect] did not return anything from Dialect#getCurrentSchemaCommand
    at org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver$SchemaNameResolverFallbackDelegate.resolveSchemaName(DefaultSchemaNameResolver.java:100)
    at org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver.resolveSchemaName(DefaultSchemaNameResolver.java:76)

推荐答案

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.5</version>
</dependency>

代替

<dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
    </dependency>

是解决方案

这篇关于实现方法 org.postgresql.jdbc4.Jdbc4Connection.getSchema()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 18:35