Uploaded image for project: 'Hibernate ORM'
  1. HHH-10977

entity not enhanced when mapped superclass enhanced before

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      When a mapped superclass gets enhanced before a subclassing entity, the entity does not get enhanced itself. An entity does get enhanced if it comes before the mapped superclass.

      Find attached a sample project that reproduces this behaviour. Both AEntity and CEntity subclass BSuperclass. AEntity gets enhanced, CEntity does not.

      Run with mvn test produces:

      [INFO] Successfully enhanced class [eu.pinske.model.CEntity]
      

      But the check fails:

      Assert.assertTrue("C not enhanced", ManagedEntity.class.isAssignableFrom(CEntity.class));
      
      test(eu.pinske.test.EnhanceTest)  Time elapsed: 0.056 sec  <<< FAILURE!
      java.lang.AssertionError: C not enhanced
      

      I guess this is due to this check in org.hibernate.bytecode.enhance.spi.Enhancer

      if ( PersistentAttributesHelper.isAssignable( managedCtClass, Managed.class.getName() ) ) {
          log.debugf( "Skipping enhancement of [%s]: already enhanced", managedCtClass.getName() );
          return;
      }
      

      After the mapped superclass has itself been enhanced (it then implements Managed), the entity does also already implement that, despite not having been enhanced itself.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: