Skip to content

NoSuchMethodException when reading @Embeddable record  #36747

@thomasnaudin

Description

@thomasnaudin

Describe the bug

Migrating from Quarkus 3.2 to Quarkus 3.5, I had to add @Embeddable on my @Embedded records.

I have a basic MailAddress record :

@Embeddable
public record MailAddress(String value) {
}

This code throws a NoSuchMethodException :

var mailAddress = new MailAddress("some@random.mail");
mailAddress.value(); // Error

Here's the error :

java.lang.NoSuchMethodError: 'java.lang.String fr.mydompro.accounting.valueobject.MailAddress.$$_hibernate_read_value()'

If I remove the @Embeddable annotation, the code works as expected.

It's to highlight that I can actually read fields of embedded records when they're loaded by JPA.

var user = userRepository.findByLogin("randomLogin");
user.getEmail().value(); // Works

Expected behavior

Calling an embeddable record accessor should not lead to call some hibernate proxy method.

Actual behavior

Calling an embeddable record accessors doesn't work as expected : it seems that a call to some hibernate proxy method is made, even if the record has been manually instantiated.

How to Reproduce?

  • create a java record
  • annotate it with @Embeddable
  • manually instantiate the record
  • call accessors

Output of uname -a or ver

Linux orion 6.5.7-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 11 04:07:58 UTC 2023 x86_64 GNU/Linux

Output of java -version

openjdk version "21" 2023-09-19 OpenJDK Runtime Environment (Red_Hat-21.0.0.0.35-1.rolling.fc38) (build 21+35) OpenJDK 64-Bit Server VM (Red_Hat-21.0.0.0.35-1.rolling.fc38) (build 21+35, mixed mode, sharing)

Quarkus version or git rev

3.5

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

Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f) Maven home: /home/thomas/.m2/wrapper/dists/apache-maven-3.9.3-bin/326f10f4/apache-maven-3.9.3 Java version: 21, vendor: Eclipse Adoptium, runtime: /home/thomas/.jbang/cache/jdks/21 Default locale: fr_FR, platform encoding: UTF-8 OS name: "linux", version: "6.5.7-200.fc38.x86_64", arch: "amd64", family: "unix"

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions