MyMainClass.class META-INF\ entities.jar persistence.xml
The entities.jar file contains a simple JPA entity `test.MyEntity` annotated with @Entity. The persistence.xml contains `<jar-file>META-INF/entities.jar</jar-file>`
I don't agree with putting the entities.jar in the META-INF folder but I assume that is showing the described problem that the persistence unit root is not used to find the jar-file element. The below text is from the above mentioned JPA 2.1 spec section:
8.2.1.6.3 Jar Files One or more JAR files may be specified using the jar-file elements instead of, or in addition to the mapping files specified in the mapping-file elements. If specified, these JAR files will be searched for managed persistence classes, and any mapping metadata annotations found on them will be processed, or they will be mapped using the mapping annotation defaults defined by this specification.Such JAR files are specified relative to the directory or jar file that contains [89] the root of the persistence unit. [90]
[89] This semantics applies to persistence.xml files written to the persistence_2_0.xsd or later schema. Due to ambiguity in the Java Persistence 1.0 specification, provider-specific interpretation of the relative references used by this element may apply to earlier versions. [90] Persistence providers are encouraged to support this syntax for use in Java SE environments.
I'm not sure if Hibernate is or is not currently finding the jar-file via persistence unit root, which is required for JPA 2.0 + greater. |