This might be a duplicate of HHH-12601, but the code mentioned in that ticket is completely different from the one I encountered while analyzing the problem, so I'm not sure.
When you define a public field in a mapped superclass or in an entity superclass, inherited by an entity class:
{code} @Entity(name = "entitySuper") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public static class MyEntitySuperClass {
@Id @GenericField public Integer id;
}
@Entity @Indexed public static class MyEntity extends MyEntitySuperClass {
@Basic public String name;
} {code}
And access the id defined in the superclass on an instance of the child class:
{code} MyEntity entity1 = new MyEntity(); entity1.id = 1; // Id is not defined in MyEntity, but in its superclass {code}
Then enhancement of the code above will fail with this error:
{noformat} Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Failed to enhance class org.hibernate.search.integrationtest.mapper.orm.model.BytecodeEnhancementIT at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:138) at org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner$EnhancingClassLoader.loadClass(BytecodeEnhancerRunner.java:219) ... 18 more Caused by: org.hibernate.bytecode.enhance.spi.EnhancementException: Unable to perform extended enhancement - No unique field [id] defined by [org.hibernate.search.integrationtest.mapper.orm.model.BytecodeEnhancementIT$IndexedEntity] at org.hibernate.bytecode.enhance.internal.bytebuddy.FieldAccessEnhancer.findField(FieldAccessEnhancer.java:131) at org.hibernate.bytecode.enhance.internal.bytebuddy.FieldAccessEnhancer.access$000(FieldAccessEnhancer.java:33) at org.hibernate.bytecode.enhance.internal.bytebuddy.FieldAccessEnhancer$1.visitFieldInsn(FieldAccessEnhancer.java:66) at net.bytebuddy.jar.asm.ClassReader.readCode(ClassReader.java:2415) at net.bytebuddy.jar.asm.ClassReader.readMethod(ClassReader.java:1488) at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:718) at net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:401) at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:3827) at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:2166) at net.bytebuddy.dynamic.scaffold.inline.RedefinitionDynamicTypeBuilder.make(RedefinitionDynamicTypeBuilder.java:224) at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3588) at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.make(ByteBuddyState.java:197) at org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.rewrite(ByteBuddyState.java:146) at org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.enhance(EnhancerImpl.java:132) ... 19 more {noformat} |
|