[hibernate-issues] [JIRA] (HHH-14006) Extended Bytecode enhancement fails for inherited public fields

Yoann Rodière (JIRA) jira at hibernate.atlassian.net
Mon May 11 03:17:10 EDT 2020


Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A58fa1ced-171a-4c00-97e8-5d70d442cc4b ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14006?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 ) HHH-14006 ( https://hibernate.atlassian.net/browse/HHH-14006?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 ) Extended Bytecode enhancement fails for inherited public fields ( https://hibernate.atlassian.net/browse/HHH-14006?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 )

Change By: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A58fa1ced-171a-4c00-97e8-5d70d442cc4b )

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}

( https://hibernate.atlassian.net/browse/HHH-14006#add-comment?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14006#add-comment?atlOrigin=eyJpIjoiNWQ5MjI0N2I3ZmRkNDg5OWFjODcyNjMzMGEyNTZmZmYiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100126- sha1:c6335f4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200511/b4a335ff/attachment.html 


More information about the hibernate-issues mailing list