JPA requires the persistence of classes to be defined via Metadata. This Metadata
can be provided in the following forms
XML : the traditional mechanism, with XML files
containing information for each class to be persisted.
Annotations : using JDK1.5+ annotations in the
classes to be persisted
We recommend that you use either XML or annotations for the basic persistence
information, but always use XML for ORM information. This is because it is liable to
change at deployment time and hence is accessible when in XML form whereas in annotations
you add an extra compile cycle (and also you may need to deploy
to some other datastore at some point, hence needing a different deployment).
JPA defines the priority order for metadata as being
JPA XML Metadata
If a class has annotations and JPA XML Metadata then the XML Metadata
will take precedence over the annotations (or rather be merged on top of the
By default any XML Metadata will be validated for accuracy when loading it.
Obviously XML is defined by a DTD or XSD schema and so should follow that.
You can turn off such validations by setting the persistence property
to false when creating your PMF.
Note that this only turns off the XML strictness validation, and
the checks on inconsistency of specification of relations etc.