Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException

对着背影说爱祢 提交于 2019-12-11 05:22:18

问题


I configured hibernate to use Posgresql

<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL92Dialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>

But I get exception when I start tomcat:

23-Jul-2017 21:22:25.544 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 7529 ms
23-Jul-2017 21:26:47.901 INFO [http-nio-8081-exec-9] org.hibernate.Version.logVersion HHH000412: Hibernate Core {5.2.10.Final}
23-Jul-2017 21:26:47.912 INFO [http-nio-8081-exec-9] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
23-Jul-2017 21:26:48.546 INFO [http-nio-8081-exec-9] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
23-Jul-2017 21:26:49.840 INFO [http-nio-8081-exec-9] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL92Dialect
23-Jul-2017 21:26:50.021 INFO [http-nio-8081-exec-9] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
23-Jul-2017 21:26:50.024 INFO [http-nio-8081-exec-9] org.hibernate.type.BasicTypeRegistry.register HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@4bbde374
Hibernate: 

When I insert record in Postgresql table rows are empty. How I can configure properly Hibernate?


回答1:


This exception is thrown by Hibernate and has nothing to do with Spring Boot or your implementation. This error can be suppressed by modifying your application.properties as per the instructions in this link.




回答2:


Well, it worked successfully for me with the following output:

> log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
> log4j:WARN Please initialize the log4j system properly.
Hibernate: 

    insert 
    into
        emp
        (firstName, lastName, id) 
    values
        (?, ?, ?)
Trasaction completed successfully using config!

I have used the following xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC 
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >

<hibernate-configuration>
    <session-factory>
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>

        <property name="hbm2ddl.auto" >update</property>
        <property name="dialect" >org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="connection.url">jdbc:postgresql://localhost:5432/postgres</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password">postgres</property>
        <property name="connection.driver_class">org.postgresql.Driver</property>

        <!-- Mapping Through Annotations -->
        <mapping class="hibernate.persistence.entity.Employee" />
        <mapping class="hibernate.persistence.inheritence.EmployeeInherit" />
        <mapping class="hibernate.persistence.inheritence.RegularEmployee" />
        <mapping class="hibernate.persistence.inheritence.ContractEmployee" />

        <!-- 
        <property name="hbm2ddl.auto" >update</property>
        <property name="dialect" >org.hibernate.dialect.MySQLDialect</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/test</property>
        <property name="connection.username">root</property>
        <property name="connection.password">root</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
         -->

    </session-factory>
</hibernate-configuration>

Please try using the XML file in the code. Note: Be careful of the Hibernate version.



来源:https://stackoverflow.com/questions/45268631/disabling-contextual-lob-creation-as-createclob-method-threw-error-java-lang

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!