hibernate 如何解决org.postgresql.jdbc.PgConnection. PgClob()尚未实现

yshpjwxd  于 2023-10-23  发布在  PostgreSQL
关注(0)|答案(3)|浏览(192)

异常

当启动spring-boot应用程序时,我收到了:
原因:java.sql.SQLFeatureNotSupportedException:尚未实现方法org.postgresql.jdbc.PgConnection. PgClob()。
我知道这与我现在使用的PostgreSQL驱动程序的一些问题有关。

尝试失败

许多人解决了这个问题,只是把下面这行在application.properties文件:
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=true
我仍然有同样的问题。还有其他的小费吗?如果考虑看到我的项目与当前配置:https://github.com/caliari77/hiRank

sczxawaw

sczxawaw1#

尝试添加

  1. spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
6xfqseft

6xfqseft2#

经过一些测试,我可以解决这个问题。看起来Hibernate实现丢失了,所以为了解决这个问题,我在www.example.com文件中添加了它gradle.build。我以为Spring-boot在获取JPA时已经处理了它,但我错了。这是我从gradle.build更新的依赖项:

  1. dependencies {
  2. //Spring
  3. //implementation 'org.springframework.boot:spring-boot-starter-actuator'
  4. implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
  5. implementation 'org.springframework.boot:spring-boot-starter-web'
  6. //runtimeOnly 'org.springframework.boot:spring-boot-devtools'
  7. testImplementation 'org.springframework.boot:spring-boot-starter-test'
  8. //Hibernate
  9. implementation 'org.hibernate:hibernate-core:5.4.2.Final'
  10. implementation 'org.hibernate:hibernate-entitymanager:5.4.2.Final'
  11. //Postgres
  12. implementation 'org.postgresql:postgresql:42.2.5.jre7'
  13. //Gson
  14. implementation 'com.google.code.gson:gson:2.8.5'
  15. //Logger
  16. implementation 'log4j:log4j:1.2.17'

}

展开查看全部
1qczuiv0

1qczuiv03#

我也遇到过类似的问题,不过是在一个较老的grails应用程序中。当我们用Hikari替换c3p0连接池时,问题就开始了。
在hibernate.cfg文件中设置属性的常规解决方案仅适用于第一个JavaScript,但我们有第二个jpa JavaScript,它被定义为xml中的bean。
最后发现,将以下片段添加到相关实体ManagerFactory修复了这个问题:

  1. <bean id="mediationEntitiyManagerFactory"
  2. class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  3. <property name="dataSource" ref="mediationDataSource" />
  4. <property name="packagesToScan" value="..."/>
  5. <property name="jpaVendorAdapter">
  6. <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
  7. </property>
  8. <!-- Using HikariCP, gave the warning: Connection org.postgresql.jdbc.PgConnection@270d7864
  9. marked as broken because of SQLSTATE(0A000), ErrorCode(0) java.sql.SQLFeatureNotSupportedException.
  10. Setting this property is to avoid that warning
  11. Hibernate before v5.4.0.CR1 has an issue with this, see
  12. https://stackoverflow.com/questions/49110818/method-org-postgresql-jdbc-pgconnection-createclob-is-not-yet-implemented
  13. This is what fixed it for jBillingMediationDataSource bean
  14. -->
  15. <property name="jpaProperties">
  16. <props>
  17. <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
  18. <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
  19. </props>
  20. </property>
  21. </bean>

希望这对遇到这个问题的人有所帮助。

展开查看全部

相关问题