Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10767

<exclude-unlisted-classes> is read incorrectly in PersistenceUnitReader

    Details

      Description

      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>.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                guitarking117 Nick Williams
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  26 weeks, 3 days ago