|
In JPA 1.0's persistence.xml, <exclude-unlisted-classes> defaulted to false (providers always scanned for entities). As of JPA 2.0, <exclude-unlisted-classes> was changed to default to true. However, Hibernate EntityManager does not honor this. See lines 219-221 of PersistenceXmlParser.java:
else if ( tag.equals( "exclude-unlisted-classes" ) ) {
persistenceUnit.setExcludeUnlistedClasses( true );
}
This has two consequences:
-
If you omit <exclude-unlisted-classes>, Hibernate will scan for entities, which is not compliant. Hibernate should default to the right value based on the JPA version.
-
If you intentionally add <exclude-unlisted-classes>false</exclude-unlisted-classes> to persistence.xml to enable scanning, Hibernate will disable scanning, which is downright incorrect.
This probably makes more sense:
else if ( tag.equals( "exclude-unlisted-classes" ) ) {
persistenceUnit.setExcludeUnlistedClasses( extractBooleanContent(element, !isJpaGte20) );
}
...
private static boolean extractBooleanContent(Element element, boolean defaultBool) {
String content = extractContent( element, null );
if (content != null && content.length() > 0) {
return Boolean.valueOf(content);
}
return defaultBool;
}
I don't know where the imaginary isJpaGte20 variable would come from.
|