Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPA: Using generic @Embeddable in Entities produces io.quarkus.builder.BuildException #36065

Closed
mensinda opened this issue Sep 21, 2023 · 2 comments · Fixed by #36087
Closed
Assignees
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Milestone

Comments

@mensinda
Copy link

Describe the bug

When using an @Embedded field of a generic @Embeddable class, Quarkus / Hibernate now throws an error.

Expected behavior

No error

Actual behavior

java.lang.RuntimeException:
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#defineJpaEntities threw an exception: java.lang.IllegalStateException: io.quarkus.builder.BuildException: Build failure: root.StatusEnum is used as an embeddable but does not have an @Embeddable annotation.
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:867)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:282)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:833)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: io.quarkus.builder.BuildException: Build failure: root.StatusEnum is used as an embeddable but does not have an @Embeddable annotation.
	at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.validateEmbeddable(JpaJandexScavenger.java:510)
	at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.collectEmbeddedTypes(JpaJandexScavenger.java:489)
	at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.collectEmbeddedTypes(JpaJandexScavenger.java:495)
	at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.enlistEmbeddedsAndElementCollections(JpaJandexScavenger.java:323)
	at io.quarkus.hibernate.orm.deployment.JpaJandexScavenger.discoverModelAndRegisterForReflection(JpaJandexScavenger.java:96)
	at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.defineJpaEntities(HibernateOrmProcessor.java:409)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:858)
	... 6 more

How to Reproduce?

  1. clone https://github.com/mensinda/quarkus-stuff/tree/embeddedError
  2. checkout the embeddedError branch
  3. run mvn clean verify

Output of uname -a or ver

Linux XXXXXX 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 17.0.8.1 2023-08-24

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.4.1

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

Apache Maven 3.9.2 (c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)

Additional information

Code:

public enum StatusEnum implements StatusInterface {
    OK(1), WARNING(2), ERROR(3);
    // ...
}

@Embeddable
public class StatusEmbeddable<T extends StatusInterface> {

    public int code;
    public String name;

    // ...
}

@Entity
public class StatusStorageEntity {

    @Id
    long id;

    // This does no longer work!
    @Embedded
    private StatusEmbeddable<StatusEnum> embeddedStatus;
}
@mensinda mensinda added the kind/bug Something isn't working label Sep 21, 2023
@geoand geoand added area/hibernate-orm Hibernate ORM and removed triage/needs-triage labels Sep 22, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 22, 2023

/cc @Sanne (hibernate-orm), @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

@yrodiere yrodiere self-assigned this Sep 22, 2023
@yrodiere
Copy link
Member

Thanks for reporting, yes this slipped through the cracks, it makes sense that this bug occurs when one looks at the code. I'll try to submit a patch ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants