Metode org.postgresql.jdbc.PgConnection.createClob () belum diimplementasikan

99

Bagaimana saya bisa mengatasi kesalahan ini:

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
Sandeep Malviya
sumber
1
"hibernate dengan c32p0 ..." tidak menyebutkan Spring Boot, meskipun jawabannya memang
Pafnucy

Jawaban:

29

Saya memiliki masalah serupa. Saya mengikuti solusi ini dan berhasil untuk saya

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
Prasad Paravatha
sumber
Ini berhasil untuk saya. Namun, saya menggunakan spring.jpa.database=POSTGRESQLalih-alih dialek.
cbmeeks
29

Ini adalah masalah Hibernatekemudian sebagai solusi, Anda dapat menggunakan bendera berikut. Setel konfigurasi berikut di properti Anda:

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

Untuk Spring boot 2.xx , flag ini hanya menonaktifkan pembuatan LOB kontekstual, tetapi jika Anda benar-benar ingin mengetahui jawaban yang benar, periksa UPDATE V1 .

DIPERBARUI V1

Ini adalah masalah Hibernate . Jika Anda menggunakan Spring Boot versi terbaru dari 2.0.xhingga 2.1.x disertakan, Hibernate 5.3.10.finalAnda dapat melihat di sini tetapi masalah ini telah diperbaiki pada Hibernate version 5.4.0.CR1 maka Anda perlu menambahkan ketergantungan itu atau jika mungkin versi terbaru:

Untuk Gradle:

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

Untuk Maven:

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

DIPERBARUI V2 "SPRING BOOT 2.2.0.M (1-4)"

Selain itu Spring boot v2.2.0.Mxtermasuk sekarang Hibernate v5.4.xmaka masalah ini telah diperbaiki untuk versi ini.

Jonathan JOhx
sumber
1
Keren saya menambahkan lebih banyak informasi tentang itu dan memperbarui dukungan versi untuk boot musim semi. @ShekhFirozAlam
Jonathan JOhx
Di Spring Boot 2.2.1.RELEASE, masih ada masalah. jawaban mohammad hejazi berhasil. stackoverflow.com/a/54288767/4766882
Dennis Kim
13

Dipecahkan dengan menambahkan hibernate.properties dengan

hibernate.jdbc.lob.non_contextual_creation=true

Solusi lain dengan application.properties tidak berhasil. Ini juga dapat dilakukan melalui XML hibernate.cfg.xml

Versi Spring Boot: 2.0.2.RELEASE

Pafnucy
sumber
1
apakah Anda yakin Anda mulai dengan spring.jpa? ini berfungsi dengan baik di 2.0.3 untuk saya
Kalpesh Soni
@Alpeshoni maaf, tidak bisa menjawab. Ini adalah proyek pegas dengan ketergantungan bisnis dari proyek lain, di mana hal-hal ketekunan didefinisikan. Sulit untuk mereproduksi pengaturan ini untuk mengetahuinya.
Pafnucy
11

Dipecahkan dengan menggunakan konfigurasi Yaml berikut ini:

spring:
  jpa:
    properties:
      hibernate:
        jdbc:
          lob:
            non_contextual_creation: true
    database-platform: org.hibernate.dialect.PostgreSQL9Dialect
Bhuwan Prasad Upadhyay
sumber
8
spring:      
  jpa:
    properties:
      hibernate:
        temp:
          use_jdbc_metadata_defaults: false
        jdbc:
          lob:
            non_contextual_creation: true

use_jdbc_metadata_defaults: false atau non_contextual_creation: true dua item berfungsi dengan baik

mohammad hejazi
sumber
5

Menghadapi masalah yang sama dengan versi Spring Boot: 2.1.x.RELEASE juga. itu bekerja dengan:

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true 
Nuwan Gunarathna
sumber
Ya, tapi tidak berhasil. Apakah ada cara lain?
HB
0

Saya berjuang dengan hal ini selama sehari.

  • Versi boot musim semi 2.2.5

  • Postgres: 42.2.10

  • Versi Postgres di server: PostgreSQL 11.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.3, 64-bit

Saya menggunakan data Spring JPA dengan konfigurasi Hibernate. Menggunakan sessionFactory.

Konfigurasi hibernasi:

@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;
}

Properti Hibernasi:

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

Tapi semuanya tidak berfungsi dengan baik. Bersedia melihat saran yang dapat membantu memecahkan masalah ini. Terima kasih banyak.

HB
sumber
ak, itu sudah terpecahkan. Saya ingin memastikan bahwa masalah ini tidak akan terjadi di Springboot 2.2.5 dan Hibernate 4.2.14 Final, saya mendapat kesalahan karena ada driver Oracle dalam aplikasi, mungkin itu menyebabkan konflik. Terima kasih.
HB