Skip to content

<exclude-unlisted-classes> is read incorrectly in PersistenceUnitReader [SPR-10767] #15393

@spring-projects-issues

Description

@spring-projects-issues

Nick Williams opened SPR-10767 and commented

This exact same problem also exists in Hibernate ORM (see attached reference URL).

In JPA 1.0's persistence.xml, <exclude-unlisted-classes> defaulted to false (providers always scanned for entities). So, you could have the following four uses of <exclude-unlisted-classes> with the indicated meanings:

  1. Omitted means don't exclude / do scan.
  2. <exclude-unlisted-classes /> means exclude / don't scan.
  3. <exclude-unlisted-classes>false</exclude-unlisted-classes> means don't exclude / do scan.
  4. <exclude-unlisted-classes>true</exclude-unlisted-classes> means exclude / don't scan.

As of JPA 2.0, <exclude-unlisted-classes> was changed to default to true:

  1. Omitted means exclude / don't scan.
  2. <exclude-unlisted-classes /> means exclude / don't scan.
  3. <exclude-unlisted-classes>false</exclude-unlisted-classes> means don't exclude / do scan.
  4. <exclude-unlisted-classes>true</exclude-unlisted-classes> means exclude / don't scan.

However, PersistenceUnitReader sets the value of ExcludeUnlistedClasses to true if <exclude-unlisted-classes> is merely present, regardless of its value...

...
        Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
        if (excludeUnlistedClasses != null) {
            unitInfo.setExcludeUnlistedClasses(true);
        }
...

...and leaves it as the default value (false in MutablePersistenceUnitInfo) if <exclude-unlisted-classes> is missing. This is incorrect. It will result in the default value being incorrect in JPA 2.0/2.1, and in the value being incorrectly set if persistence.xml contains <exclude-unlisted-classes>false</exclude-unlisted-classes>.


Affects: 3.1 GA, 3.2 GA, 4.0 M1

Reference URL: https://hibernate.atlassian.net/browse/HHH-8364

Issue Links:

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions