Skip to content

JPA Entities with fields from super classes fail to enhance from 3.17 onward #46402

@danpfe

Description

@danpfe

Describe the bug

I have a structure where both VO (for REST-interfaces) and JPA-Entities inherit from one base-class, let's call this BaseDO. The BaseDO defines a number of attributes that both Value Objects for my REST Resources and my JPA Entities share. Amongst others "id".

The attributes have corresponding getters and setters in the BaseDO and my BaseEntity (a MappedSuperclass) inherits from this BaseDO and dresses the properties with JPA-annotations.

Ultimately, I have a class called UserEntity which inherits from BaseEntity, which only defines the fields and properties that are relevant to that entity.

As such

public abstract class BaseDO implements Serializable {
  protected UUID id;

  public UUID getId() {
    return id;
  }

  public void setId(final UUID id) {
    this.id = id;
  }

  // ... a bunch more
}

@MappedSuperclass
public abstract class BaseEntity extends BaseDO {
  @Column(name = "id")
  @Id
  @Override
  public UUID getId() {
    return super.getId();
  }

  // ... a bunch of other stuff
}

@Entity
@Table(name = "app_user")
public class UserEntity extends BaseEntity {
  private String email;
  private String name;

  // ... getters and setters
}

Building this application works fine up to and including version 3.16.4, and fails to build from 3.17 and onward (including the latest 3.18.3) with org.hibernate.bytecode.enhance.spi.EnhancementException: Enhancement of [myapp.UserEntity] failed because no field named [id] could be found for property accessor method [getId]. To fix this, make sure all property accessor methods have a matching field..

Expected behavior

Application is compiled and successfully packaged as in 3.16.4.

Actual behavior

The quarkus-maven-plugin fails quoting following error: org.hibernate.bytecode.enhance.spi.EnhancementException: Enhancement of [myapp.UserEntity] failed because no field named [id] could be found for property accessor method [getId]. To fix this, make sure all property accessor methods have a matching field.

How to Reproduce?

Example given in bug description.

Output of uname -a or ver

Darwin Kernel Version 24.3.0

Output of java -version

OpenJDK Runtime Environment Temurin-21.0.6+7 (build 21.0.6+7-LTS)

Quarkus version or git rev

3.18.3

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.9

Additional information

No response

Metadata

Metadata

Assignees

Labels

area/hibernate-ormHibernate ORMkind/bug-thirdpartyBugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.triage/regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions