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 / Hibernate startup error with specific @IdClass setup since 3.15.2 #45879

Open
mensinda opened this issue Jan 27, 2025 · 3 comments
Open
Labels
area/hibernate-orm Hibernate ORM kind/bug-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.

Comments

@mensinda
Copy link

Describe the bug

Given the following setup:

@MappedSuperclass
public abstract class TupAbstractEntity {
    @Id
    private String oid;
}

@Entity
public class DummyEntity extends TupAbstractEntity {
}

public class CompositeIdClass {
    private String oid;
    private String myId;
}

@Entity
@IdClass(CompositeIdClass.class)
public class TestEntity extends TupAbstractEntity {
    @Id
    private String myId;
}

Starting quarkus fails with this setup with a java.lang.IllegalArgumentException: expecting IdClass mapping exception. Removing the DummyEntity or making it not extend TupAbstractEntity will get rid of the error, so the problem is not with the composite key definition in the TestEntity.

Additionally, renaming TestEntity to FooEntity also causes the error to disappear. However, renaming entities is not a viable workaround for our use-case.


This bug first occurred in Quarkus 3.15.2 and is still present in 3.17.8. The same test succeeds with Quarkus 3.15.1.

Expected behavior

No error

Actual behavior

The following exception:

java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:634)
        at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:718)
        at java.base/java.util.Optional.orElseGet(Optional.java:364)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:305)
        at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:248)
        at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:601)
        at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:651)
        ... 1 more
Caused by: jakarta.persistence.PersistenceException: [PersistenceUnit: <default>] Unable to build Hibernate SessionFactory
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:129)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:89)
        at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:73)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
        at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:154)
        at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:61)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalArgumentException: expecting IdClass mapping
        at org.hibernate.metamodel.internal.AttributeFactory.resolveVirtualIdentifierMember(AttributeFactory.java:715)
        at org.hibernate.metamodel.internal.AttributeFactory.resolveEntityMember(AttributeFactory.java:765)
        at org.hibernate.metamodel.internal.AttributeFactory.resolveMappedSuperclassMember(AttributeFactory.java:781)
        at org.hibernate.metamodel.internal.AttributeFactory.lambda$static$2(AttributeFactory.java:746)
        at org.hibernate.metamodel.internal.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:460)
        at org.hibernate.metamodel.internal.AttributeFactory.buildAttribute(AttributeFactory.java:122)
        at org.hibernate.metamodel.internal.AttributeFactory.buildAttribute(AttributeFactory.java:108)
        at org.hibernate.metamodel.internal.MetadataContext.buildAttribute(MetadataContext.java:287)
        at org.hibernate.metamodel.internal.MetadataContext.wrapUp(MetadataContext.java:372)
        at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.processJpa(JpaMetamodelImpl.java:618)
        at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:215)
        at org.hibernate.internal.SessionFactoryImpl.initializeMappingModel(SessionFactoryImpl.java:373)
        at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:302)
        at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:87)
        ... 6 more

How to Reproduce?

I have created a minimal test case for this issue: https://github.com/mensinda/quarkus-stuff/tree/compositeFail

Steps to reproduce:

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

Change the quarkus.platform.version in the pom.xml to 3.15.1 and the test passes without error.

Output of uname -a or ver

Linux XXXXXXXXX 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.5" 2024-10-15

Quarkus version or git rev

3.15.2 - 3.17.8

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

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)

Additional information

No response

@mensinda mensinda added the kind/bug Something isn't working label Jan 27, 2025
@quarkus-bot quarkus-bot bot added the area/hibernate-orm Hibernate ORM label Jan 27, 2025
Copy link

quarkus-bot bot commented Jan 27, 2025

/cc @gsmet (hibernate-orm)

@mbladel
Copy link
Member

mbladel commented Jan 27, 2025

Hello @mensinda, thank you for reporting the issue and providing a reproducer.

This looks like an Hibernate ORM bug, and I suspect it's not related with Quarkus. Could you please open an issue in Hibernate's tracker including the reproducer you linked here? A plain Hibernate test based on our templates would be even better, but this looks fairly easy to reproduce so not strictly required.

@mensinda
Copy link
Author

I was able to reproduce it upstream:

@gsmet gsmet added kind/bug-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus. and removed kind/bug Something isn't working labels Feb 11, 2025
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-thirdparty Bugs that are caused by third-party components and not causing a major dysfunction of core Quarkus.
Projects
None yet
Development

No branches or pull requests

3 participants