Some people, including me, have been struggling with merging entities from different modules (jars) into a single persistence unit (especially with JavaSE, for
Yes, this is allowed by the JPA specification.
XML entity mappings are designed to override JPA annotations.
Unless you specifically change the default behavior using <xml-mapping-metadata-complete/>
tag, JPA provider will use annotations where there is no XML mapping.
Here is an excerpt from the JPA 2.0 spec:
12.1 Use of the XML Descriptor
... The absence or present of the xml-mapping-metadata-complete subelement contained in the persistence-unit-defaults subelement of the entity-mappings element controls whether the XML object/relational mapping descriptor is used to selectively override annotation values or whether it serves as a complete alternative to Java language metadata annotations.
If the xml-mapping-metadata-complete subelement is specified, the complete set of mapping metadata for the persistence unit is contained in the XML mapping files for the persistence unit, and any persistence annotations on the classes are ignored.