【问题标题】:Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented方法 org.postgresql.jdbc.PgConnection.createClob() 尚未实现
【发布时间】:2018-08-13 03:06:20
【问题描述】:

我该如何解决这个错误:

java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
    at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation(LobCreatorBuilderImpl.java:113) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.makeLobCreatorBuilder(LobCreatorBuilderImpl.java:54) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentImpl.<init>(JdbcEnvironmentImpl.java:271) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:114) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:861) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:388) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) [spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) ~[spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at com.divergent.demo.DemoApplication.main(DemoApplication.java:12) ~[classes/:na]



Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
    at org.postgresql.Driver.notImplemented(Driver.java:683) ~[postgresql-42.2.1.jar:42.2.1]
    at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1252) ~[postgresql-42.2.1.jar:42.2.1]
    ... 44 common frames omitted

【问题讨论】:

标签: java spring-boot


【解决方案1】:

在你的 application.properties 中添加这个属性:

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

参考:

【讨论】:

  • 不适用于 Spring Boot 2.1.6。可能有regression。
  • 工作于 2.1.9 RELEASE。
  • 不适用于 Spring Boot 2.4.4。最后我发现这是一个hibernate错误,所以1)我删除了上面的配置+ 2)将Hibernate版本从5.2.10.Final升级到5.4.2.Final。比开始工作了。 stackoverflow.com/questions/55732898/…
【解决方案2】:

这是Hibernate 的问题,作为一种解决方法,您可以使用以下标志。然后在您的属性中设置以下配置:

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

对于 Spring boot 2.x.x,此标志只是禁用上下文 LOB 创建,但如果您真的想知道正确答案,请检查 UPDATE V1。

更新的 V1

这是一个休眠issue。 如果您使用 Spring Boot 最新版本从 2.0.x 到 2.1.x 包括Hibernate 5.3.10.final 你可以看看here 但是这个问题在Hibernate version 上得到了修复5.4.0.CR1 那么你需要添加那个依赖或者如果它可能是最新版本:

对于 Gradle:

compile('org.hibernate:hibernate-core:5.4.2.Final')

对于 Maven:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.4.2.Final</version>
</dependency>

更新的 V2“SPRING BOOT 2.2.0.M(1-4)”

此外,Spring boot v2.2.0.Mx 现在包括 Hibernate v5.4.x,然后针对这些版本修复了此问题。

【讨论】:

  • 酷我添加了更多关于它的信息并更新了对 Spring Boot 版本的支持。 @ShekhFirozAlam
  • 在 Spring Boot 2.2.1.RELEASE 中,问题仍然存在。 mohammad hejazi 的回答奏效了。 stackoverflow.com/a/54288767/4766882
【解决方案3】:

我有类似的问题。 我遵循了这个解决方案,它对我有用

http://vkuzel.blogspot.com/2016/03/spring-boot-jpa-hibernate-atomikos.html

# Disable feature detection by this undocumented parameter. Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details.
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false

# Because detection is disabled you have to set correct dialect by hand.
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect

【讨论】:

  • 这对我有用。但是,我用spring.jpa.database=POSTGRESQL 代替了方言。
【解决方案4】:

使用如下Yaml配置解决:

spring:
  jpa:
    properties:
      hibernate:
        jdbc:
          lob:
            non_contextual_creation: true
    database-platform: org.hibernate.dialect.PostgreSQL9Dialect

【讨论】:

    【解决方案5】:

    通过添加hibernate.properties和

    解决
    hibernate.jdbc.lob.non_contextual_creation=true
    

    application.properties 的其他解决方案无效。这也可以通过 XML hibernate.cfg.xml 来完成

    Spring Boot 版本:2.0.2.RELEASE

    【讨论】:

    • 你确定你是从 spring.jpa 开始的吗?这对我来说在 2.0.3 中运行良好
    • @KalpeshSoni 抱歉,无法回答。它是一个 spring-boot 项目,具有另一个项目的业务依赖关系,其中定义了持久性内容。很难重现此设置以弄清楚。
    【解决方案6】:
    spring:      
      jpa:
        properties:
          hibernate:
            temp:
              use_jdbc_metadata_defaults: false
            jdbc:
              lob:
                non_contextual_creation: true
    

    use_jdbc_metadata_defaults:假 要么 non_contextual_creation: true 两项工作正常

    【讨论】:

      【解决方案7】:

      Spring Boot 版本也面临同样的问题:2.1.x.RELEASE。 它适用于:

      spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true 
      

      【讨论】:

      • 我做了,但它不起作用。还有其他方法吗?
      【解决方案8】:

      我在这些东西上苦苦挣扎了一天。

      • Spring boot 版本2.2.5

      • Postgres:42.2.10

      • 服务器上的 Postgres 版本:PostgreSQL 11.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit

      我在 Hibernate 配置中使用 Spring JPA 数据。使用 sessionFactory。

      休眠配置:

      @Bean(name = "sessionFactory")
      @Primary
      public LocalSessionFactoryBean sessionFactory(){
          LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
          sessionFactoryBean.setDataSource(assetHealthDataSource);
          sessionFactoryBean.setMappingDirectoryLocations(new Resource[]{new ClassPathResource("mappings")});
          sessionFactoryBean.setHibernateProperties(hibernateProperties());
      
          return sessionFactoryBean;
      }
      

      休眠属性:

      private final Properties hibernateProperties() {
          Properties hibernateProperties = new Properties();
          hibernateProperties.setProperty(
                  "hibernate.dialect", "org.hibernate.dialect.PostgreSQL9Dialect");
          hibernateProperties.setProperty(
                  "hibernate.jdbc.lob.non_contextual_creation", "true");
          hibernateProperties.setProperty(
                  "hibernate.temp.use_jdbc_metadata_defaults", "false");
          hibernateProperties.setProperty(
                  "hibernate.show_sql", environment.getProperty("assetHealthDataSource.hibernate.showSQL"));
          hibernateProperties.setProperty(
                  "hibernate.format_sql", environment.getProperty("assetHealthDataSource.hibernate.formatSQL"));
          hibernateProperties.setProperty(
                  "hibernate.transaction.auto_close_session", "false");
          hibernateProperties.setProperty(
                  "hibernate.hibernate.connection.release_mode", "auto");
          hibernateProperties.setProperty(
                  "hibernate.hikari.maximumPoolSize", "3");
          hibernateProperties.setProperty(
                  "hibernate.default_schema", "MY_SCHEMA");
      
          return hibernateProperties;
      }
      

      但是一切都没有正常工作。愿意看到任何可以帮助解决这个问题的建议。 非常感谢。

      【讨论】:

      • ak,解决了。我想确认这个问题在 Springboot 2.2.5 和 Hibernate 4.2.14 Final 中不会出现,我得到这个错误是因为应用程序中有一个 Oracle 驱动程序,可能是它导致了冲突。谢谢。
      猜你喜欢
      • 2019-09-08
      • 2017-10-09
      • 2019-12-13
      • 2014-10-25
      • 1970-01-01
      • 2021-03-13
      • 2016-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多