Search code examples
javahibernatejpaconnection-poolingweblogic12c

HHH10001002: Using Hibernate built-in connection pool (not for production use!)


While Deployment of my application i got this hibernate warning (twice):

WARN  org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)

I don't want to use either these built-in connection pool from Hibernate, nor any other implementation like C3PO.

I tried a lot of things, but i was not able to use the connection pooling of my Weblogic Application Server.

My persistence.xml:

<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
    <description>Hibernate JPA Configuration</description>
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

    <class>some classes...</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
        <property name="hibernate.connection.datasource" value="jdbc/myDS"/>
        <property name="hibernate.hbm2ddl.auto" value="none"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
        <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
        <property name="jndi.class" value="weblogic.jndi.WLInitialContextFactory"/>
    </properties>
</persistence-unit>
</persistence>

weblogic.xml:

    ...
    <resource-description>
        <res-ref-name>jdbc/myDS</res-ref-name>
        <jndi-name>myDS</jndi-name>
    </resource-description>
    ...

web.xml:

...
    <resource-ref>
       <res-ref-name>jdbc/myDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
    </resource-ref>
...

PS: I'm getting the Connection via the Entitymanager and i don't have any context.xml.

What can i do? Can anybody help?


Solution

  • You shouldn't be setting the datasource using properties. There is and standard way to provide the datasource to the entity manager, using the <jta-data-source> element.

    You only should need something like this:

    <persistence...
    <persistence-unit name="MY-PERSISTENCE-UNIT">
        <description>Hibernate JPA Configuration</description>
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    
        <jta-data-source>jdbc/myDS</jta-data-source>    
    
        <class>some classes...</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
    
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="none"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
        </properties>
    </persistence-unit>
    </persistence>