Persistence unit:
defines a set of all entity classes
in a single data store
that are managed by EntityManager instances in an application
defined by persistence.xml
persistence.xml
placed in
root/META-INF
above "root" means a JAR file or a directory
scope of persistence unit is determined by the persistence unit's root
each persistence unit must be identified by a unique name within the scope
if packaged as a set of classes in EJB JAR, put into META-INF dir
if packaged in WAR, put into WEB-INF/classes/META-INF
if packaged in JAR that will be included in EAR or WAR, the JAR should be put in
WEB-INF/lib dir of a WAR, or
EAR's library dir
data source
jta-data-source : global JNDI name
non-jta-data-source : global JNDI name
managed persistence classes
jar-file : JAR file containing the managed persistence classes
class :
Example:
<persistence>
<persistence-unit name="OrderManagement">
<description>This unit manages orders and customers.
It does not rely on any vendor-specific features and can
therefore be deployed to any persistence provider.
</description>
<jta-data-source>jdbc/MyOrderDB</jta-data-source>
<jar-file>MyOrderApp.jar</jar-file>
<class>com.widgets.Order</class>
<class>com.widgets.Customer</class>
</persistence-unit>
</persistence>