Hibernate persistance.xml : Disabling contextual LOB creation as connection was null

C_B picture C_B · Jan 22, 2015 · Viewed 10.1k times · Source

My persistence.xml:

<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
  <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <class>com.ibm.apiscanner.DTO.BaselineDTO</class>
    <properties>
      <property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver" />
      <property name="hibernate.connection.url"    value="jdbc:db2://localhost:{PORT}/{DB}" />
      <property name="hibernate.connection.username" value="{user}" />
      <property name="hibernate.connection.password" value="{password}" />
      <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect"/>
      <property name="show_sql" value="true"/>
      <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
    </properties>
  </persistence-unit>
</persistence>

I'm presented with the following:

Jan 22, 2015 9:16:48 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.DB2Dialect
Jan 22, 2015 9:16:48 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null

The same url,user and password combination works when connecting via basic JDBC.

Anyone have suggestions?

Answer

Vlad Mihalcea picture Vlad Mihalcea · Jan 22, 2015

That's an INFO message (nothing to worry about) because you set:

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>

By default, if you don't specify this property, it will then be set to true, and a JDBC connection will be used to inspect the database metadata.

So you have two options:

  1. You remove that property
  2. You keep it, but you add this property as well:

    hibernate.jdbc.lob.non_contextual_creation=true
    

    but then you will get some other INFO message, telling that:

    HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true