Easy learning with example program codes

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"/>
Posted in JPA   
Sign Up/ Sign In
Ask a Question

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2018 CodesJava Protection Status SiteMap Reference: Java Wiki