JPA Persistence Unit

A persistence unit defines a set of all user defined persistable classes that are managed by EntityManager instances in an application. This set of entity classes represents the data contained within a single data store. . A Persistence each in turn containing a number of properties and attributes. Persistence units are defined in the persistence.xml file.


The persistence.xml file have to be put under the META-INF directory in the classpath. The persistence.xml file can include definitions for one or more Persistence Units. The EntityManagerFactory will need Persistence name to refer the persistence-unit.

persistence.xml example:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns=""
 xsi:schemaLocation="" version="1.0">
   <persistence-unit name="my-pu">
     <description>Test Persistence Unit</description>
     <provider> org.eclipse.persistence.jpa.PersistenceProvider </provider>
       <property name="propertyName" value="propertyValue"/>