I need to clarify a little bit more, because I don't believe I did adequately Comment obsolete .
In JPA 1 Please delete . 0, {{<exclude-unlisted-classes>}} had the following usage: # Omitted means don't exclude / do scan. # {{<exclude-unlisted-classes />}} means exclude / don't scan. # {{<exclude-unlisted-classes>false</exclude-unlisted-classes>}} means don't exclude / do scan. # {{<exclude-unlisted-classes>true</exclude-unlisted-classes>}} means exclude / don't scan.
As of JPA 2.0, {{<exclude-unlisted-classes>}} has the following usage: # Omitted means exclude / don't scan. # {{<exclude-unlisted-classes />}} means exclude / don't scan. # {{<exclude-unlisted-classes>false</exclude-unlisted-classes>}} means don't exclude / do scan. # {{<exclude-unlisted-classes>true</exclude-unlisted-classes>}} means exclude / don't scan.
With this clarification, my suggested code needs to be tweaked slightly:
{code:java}private void bindPersistenceUnit(ParsedPersistenceXmlDescriptor persistenceUnit, Element persistenceUnitElement) { ... persistenceUnit.setExcludeUnlistedClasses( !isJpaGte20 ); NodeList children = persistenceUnitElement.getChildNodes(); for ( int i = 0; i < children.getLength() ; i++ ) { ... else if ( tag.equals( "exclude-unlisted-classes" ) ) { persistenceUnit.setExcludeUnlistedClasses( extractBooleanContent(element, true) ); } ... } } ... 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; }{code}
|