1

I'm new to Hibernate and JPA in general.

I read a lot about this warning, but I still can't solve it.

The answers I read so far, said that it is necessary to have hibernate.cfg.xml in the project. But I also read that:

If you are using JPA i.e. Hibernate EntityManager, you'll need the persistence.xml. So you generally don't need both as you use either Hibernate proprietary API or JPA. (what is the purpose of two config files for Hibernate?)

Using persistence.xml I have this warning every time I use Hibernate.

This is my persistence.xml:

<persistence version="2.0"
    xmlns="http://java.sun.com/xml/ns/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">

    <persistence-unit name="integration"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

        <properties>
            <property name="hibernate.dialect"
                value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/db-name?autoReconnect=true"/>
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="root" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.id.new_generator_mappings"
                value="true" />
        </properties>
    </persistence-unit>

</persistence>

I can't figure out what I'm doing wrong.

Thanks in advances

Lulixter
  • 161
  • 1
  • 3
  • 12

2 Answers2

1

It is just a warning stating that you are using a built_in connection pool which is not a suitable solution in the production environment, you should use the application server connection pool in the production environment. depending on your application server you can setup database connection inside your application server then configure hibernate to use that connection. But if you want to solve this problem without configuring the application server you can see this.

Hadi Moloodi
  • 639
  • 7
  • 12
0

add this code (connection pool code) in persistence.xml file.