Skip to content

org.hibernate.bytecode.enhance.spi.EnhancementException: Enhancement of [org.acme.domain.MyEntity] failed #44863

@KaiSuchomel

Description

@KaiSuchomel

Describe the bug

Exception occurs during Build:
org.hibernate.bytecode.enhance.spi.EnhancementException: Enhancement of [org.acme.domain.MyEntity] failed because no field named [modelType] could be found for property accessor method [getModelType]. To fix this, make sure all property accessor methods have a matching field.

Expected behavior

The Build should succeed.

Actual behavior

When building the project:
ERROR] Caused by: java.util.concurrent.ExecutionException: org.hibernate.bytecode.enhance.spi.EnhancementException: Enhancement of [org.acme.domain.MyEntity] failed because no field named [modelType] could be found for property accessor method [getModelType]. To fix this, make sure all property accessor methods have a matching field.

How to Reproduce?

Reproducer: https://github.com/KaiSuchomel/quarkus-test/tree/hibernate
Just build the project with maven.
Simple Entity:

@Entity
public class MyEntity {

    @Id
    private UUID id;

    public UUID getId() {
        return id;
    }

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

    public void getXXX() {
    }

    @PrePersist
    public void setId(){
        id = UUID.randomUUID();
    }
    
    public String getModelType() {
        return "MyEntity";
    }
}

After changing the PrePersist setter to a seperate name the build is working:

@Entity
public class MyEntity {

    @Id
    private UUID id;

    public UUID getId() {
        return id;
    }

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

    public void getXXX() {
    }

    @PrePersist
    public void prePersistSetId(){
        id = UUID.randomUUID();
    }
    
    public String getModelType() {
        return "MyEntity";
    }
}

Output of uname -a or ver

Darwin Mac-C6VD4H4XT3 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:00:32 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6030 arm64

Output of java -version

openjdk version "21.0.5" 2024-10-15 OpenJDK Runtime Environment Homebrew (build 21.0.5) OpenJDK 64-Bit Server VM Homebrew (build 21.0.5, mixed mode, sharing)

Quarkus version or git rev

3.17.2 --> hibernate-core 6.6.3

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

Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec Java version: 21.0.5, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@21/21.0.5/libexec/openjdk.jdk/Contents/Home Default locale: de_DE, platform encoding: UTF-8 OS name: "mac os x", version: "15.1.1", arch: "aarch64", family: "mac"

Additional information

@yrodiere Can you please check. Thx.
See: hibernate/hibernate-orm@b5221e2#diff-5f775bce3db8bc5527104f2eba37fef522276d3bed00a3276545528ab233c380R16

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.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions