2

The exception

When starting spring-boot application I've received:

Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.

I know this is related to some issue from Postgresql driver, which I am using now.

Unsucessful attempt

Many people resolved the problem just putting this following line in application.properties file:

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=true

I still have the same issue. Is there any other tip for It? In case thinking about see my project with current configuration: https://github.com/caliari77/hiRank

OneNoOne
  • 587
  • 7
  • 23

3 Answers3

4

try to add

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
Christopher
  • 425
  • 3
  • 9
  • I beleive it is a hibernate error, read elsewhere, and just need to get a more recent hibernate version. – cogitoboy Apr 28 '19 at 19:48
4

After some tests I could resolve this. It seems Hibernate implementation was missing, so to resolve this I've added It in gradle.build file. I thought Spring-boot already took care of It when getting JPA, but I was wrong. Here It is my updated dependencies from gradle.build:

dependencies {

//Spring
//implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
//runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

//Hibernate
implementation 'org.hibernate:hibernate-core:5.4.2.Final'
implementation 'org.hibernate:hibernate-entitymanager:5.4.2.Final'

//Postgres
implementation 'org.postgresql:postgresql:42.2.5.jre7'

//Gson
implementation 'com.google.code.gson:gson:2.8.5'

//Logger
implementation 'log4j:log4j:1.2.17'

}

OneNoOne
  • 587
  • 7
  • 23
  • Same experience here. Seems versions 5.2.17 or hibernate-core and hibernate-entitymanager produces the error, while versions 5.4.2.Final does not. – cogitoboy Apr 28 '19 at 19:47
0

I had a similar issue, but in an older grails application. The issue started when we replaced c3p0 connection pool with Hikari.

The normal solution of setting the property in the hibernate.cfg file only works for the first datasource, but we have a second jpa datasource defined as beans in xml.

Finally figured out that adding the following fragment to the related entityManagerFactory fixed the issue:

  <bean id="mediationEntitiyManagerFactory" 
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="mediationDataSource" />
    <property name="packagesToScan" value="..."/>
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
    </property>

    <!--  Using HikariCP, gave the warning:  Connection org.postgresql.jdbc.PgConnection@270d7864
           marked as broken because of SQLSTATE(0A000), ErrorCode(0) java.sql.SQLFeatureNotSupportedException.
           Setting this property is to avoid that warning
           Hibernate before v5.4.0.CR1 has an issue with this, see
           https://stackoverflow.com/questions/49110818/method-org-postgresql-jdbc-pgconnection-createclob-is-not-yet-implemented
           This is what fixed it for jBillingMediationDataSource bean
    -->
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
        </props>
    </property>
</bean>

Hope this helps someone else who runs into this issue.