JPA - persistence.xml

Card Puncher Data Processing


The JPA specification requires the use of a persistence.xml file for deployment.

The persistence configuration file must be named “META-INF/persistence.xml” in the persistence archive.

This file defines one or more persistence unit where:

The Xsd for the persistence configuration file can be found:


Persistence configuration files must indicate

  • the persistence schema by using the persistence namespace:

  • and indicate the version of the schema by using the version element as shown below:
<persistence xmlns="" 



The provider node define the entity managers class. The provider element is optional but should be specified if the application is dependent upon a particular persistence provider being used. The class must be present in the classpath.

For EclipseLink:


For Hibernate:


For Toplink:




All the class that are unlisted will/or not be automatically discovered with reflection. Ie if the @Entity annotations is present, the class is an entity.



Eclipselink configuration for a derby database with Logging level as properties

<?xml version="2.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="" 
  <persistence-unit name="TroubleTicketSystemServer" transaction-type="RESOURCE_LOCAL">
      <property name="" value="Derby"/>            
      <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/jpatutorial;create=true"/>
      <property name="javax.persistence.jdbc.user" value="app"/>
      <property name="javax.persistence.jdbc.password" value="app"/>
      <property name="eclipselink.logging.level" value="ALL"/>            

Add the derby jars to the application classpath


<persistence version="2.0" 
    <persistence-unit name="example" transaction-type="JTA">
        <!-- optional --><class></class>
            <!-- optional --><property name="" 
            <property name="" value="WebLogic_10"/>
            <property name="eclipselink.logging.level" value="FINEST"/>

Add derby jars to the application server classpath (Example: for WebLogic place in the modules directory)


No Persistence provider for EntityManager

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named myProviderUnit:  
The following providers:
Returned null to createEntityManagerFactory.
	at javax.persistence.Persistence.createEntityManagerFactory(
	at test.Main.main(

No persistence provider node with the name myProviderUnit can be found.

Documentation / Reference

Discover More
Java Conceptuel Diagram
J2EE - JPA and Stateless Session Bean (EJB) as Data Access Object (DAO)

Stateless EJB session beans as Data Access Object (DAO) implementation with JPA. You must use the EntityManagerFactory to get an EntityManager The resulting EntityManager instance is a PersistenceContext/Cache...
Card Puncher Data Processing
JPA - Entity (Managed Classes)

xmlparserv2.jar Introduction to EclipseLink JPA (ELUG) for more information on the annotation.
Card Puncher Data Processing
JPA - Getting Started - Hello World

A simple JPA implementation that insert an “Hello World” string in a HELLO table in a relational database. This example uses the JPA reference implementation: against an Oracle Database. Maven...
One To Many Hello Data Model
JPA - How to define a @One-to-Many relationship ?

To define a one-to-many relationship, the following annotation is used @OneToMany. The Interface with parameters and default values: where: targetEntity is the entity class that is the target...
Hello Data Model Many To Many
JPA - How to model a @Many-to-Many Relationship ?

How to model a many-to-many relationship in JPA. One Hello can have several Category and One Category can have several Hello. The Ddl File: [Ddl File] One sequence: The HelloWorld entity...
Card Puncher Data Processing
JPA - Managed Class

entities, mapped superclasses, and embedded...
Card Puncher Data Processing
JPA - Open JPA

Persistence.Xml Provider: Persistence Properties: Persistence.Xml Dynamically
Card Puncher Data Processing
JPA - Persistence Properties are database and JPA provider specific. You can configure a properties (such as database connections) using: a properties file, an XML deployment descriptor (persistence.xml)...
Card Puncher Data Processing
JPA - Persistence Unit

the node provider property See chapter 8.1 of the specification
Card Puncher Data Processing
JPA - orm.xml (Mapping Descriptor files)

orm.xml is a deployment descriptors describing the object-relational mapping. The Xsd Schema file can be found: orm_2_0.xsd or in the specification...

Share this page:
Follow us:
Task Runner