I found:
- hibernate.cfg.xml is not neede
- only persistence.xml and tomee.xml are required
I give you my example:
<persistence version="1.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_1_0.xsd">
<persistence-unit name="docTracingPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:comp/env/jdbc/docTracing</jta-data-source>
<non-jta-data-source>java:comp/env/jdbc/docTracing</non-jta-data-source>
<class>com.emaborsa.doctracing.core.persistentobject.UtentePO</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.transaction.flush_before_completion" value="true"/>
<property name="hibernate.transaction.auto_close_session" value="true"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.apache.openejb.hibernate.TransactionManagerLookup" />
<property name="hibernate.transaction.flush_before_completion" value="true"/>
<property name="hibernate.transaction.auto_close_session" value="true"/>
<!-- Print SQL to stdout. -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="docTracingPU" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://127.0.0.1:5432/myDb
UserName ****
Password ****
JtaManaged false
TestWhileIdle true
InitialSize 5
</Resource>
<Resource id="docTracingPU" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://127.0.0.1:5432/myDb
UserName *****
Password *****
JtaManaged true
TestWhileIdle true
InitialSize 5
</Resource>
</tomee>