How it works...

Let's break down our persistence unit (pu).

This line defines the pu name and the transaction type used:

<persistence-unit name="ch02-jpa-pu" transaction-type="JTA">

The following line shows the provider the JPA implementation used:

<provider>org.hibernate.ejb.HibernatePersistence</provider>

It is the datasource name that will be accessed through JNDI:

<jta-data-source>userDb</jta-data-source>

This line lets all your entities be available for this pu, so you don't need to declare each one:

<exclude-unlisted-classes>false</exclude-unlisted-classes>

This block allows the database objects to be created if they don't exist:

        <properties>            <property name="javax.persistence.schema-             generation.database.action"              value="create"/> </properties> ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.