We're updating the issue view to help you get more done. 

entity not enhanced when mapped superclass enhanced before

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:

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

But the check fails:

1 Assert.assertTrue("C not enhanced", ManagedEntity.class.isAssignableFrom(CEntity.class));
1 2 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

1 2 3 4 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.

Environment

None

Status

Assignee

Luis Barreiro

Reporter

Alexander Pinske

Labels

Components

Fix versions

Affects versions

5.2.1

Priority

Major