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: {noformat} [INFO] Successfully enhanced class [eu.pinske.model.CEntity] {noformat} But the check fails: {code:java} Assert.assertTrue("A not enhanced", ManagedEntity.class.isAssignableFrom(AEntity.class)); {code} {noformat} test(eu.pinske.test.EnhanceTest) Time elapsed: 0.056 sec <<< FAILURE! java.lang.AssertionError: C not enhanced {noformat}
I guess this is due to this check in org.hibernate.bytecode.enhance.spi.Enhancer {code:java} if ( PersistentAttributesHelper.isAssignable( managedCtClass, Managed.class.getName() ) ) { log.debugf( "Skipping enhancement of [%s]: already enhanced", managedCtClass.getName() ); return; } {code}
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. |
|