实现方法org.postgresql.jdbc4.Jdbc4Connection.getSchema()

时间:2018-10-10 16:48:44

标签: java spring spring-data-jpa

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

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>

ErrorLog

    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)

1 个答案:

答案 0 :(得分:0)

<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>

是解决方案