-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Describe the bug
I recently started using Hibernate FilterDef
and Filter
in my application, and noticed that the filters are resolved in alphanumerical order.
For Example this crashes on startup (see exception below):
@Filter(name="x_filter")
public class AMyEntity extends PanacheEntity {
@FilterDef(name = "x_filter", defaultCondition = "field = 'Hello'")
public class XEntity extends PanacheEntity {
But this works just fine, at startup and in runtime:
@Filter(name="x_filter")
public class ZMyEntity extends PanacheEntity {
@FilterDef(name = "x_filter", defaultCondition = "field = 'Hello'")
public class XEntity extends PanacheEntity {
Expected behavior
FilterDef can be defined on any entity, and can be used by any Filter. No matter the order of entity classes
Actual behavior
This exception happens on startup:
2025-01-09 15:27:12,141 ERROR [io.qua.run.boo.StartupActionImpl] (Quarkus Main Thread) Error running Quarkus: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ExceptionInInitializerError
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:549)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:70)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 3 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.<clinit>(Unknown Source)
... 16 more
Caused by: org.hibernate.AnnotationException: Entity 'AMyEntity' has a '@Filter' for an undefined filter named 'x_filter'
at org.hibernate.boot.model.internal.EntityBinder.getDefaultFilterCondition(EntityBinder.java:1494)
at org.hibernate.boot.model.internal.EntityBinder.bindFilters(EntityBinder.java:1479)
at org.hibernate.boot.model.internal.EntityBinder.bindEntityClass(EntityBinder.java:241)
at org.hibernate.boot.model.internal.AnnotationBinder.bindClass(AnnotationBinder.java:401)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:257)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:281)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:324)
at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:410)
at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:78)
at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:87)
at io.quarkus.deployment.steps.ArcProcessor$notifyBeanContainerListeners1304312071.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.ArcProcessor$notifyBeanContainerListeners1304312071.deploy(Unknown Source)
... 17 more
How to Reproduce?
Reproducer: q-orm-f-def-order.zip
- unzip
- mvn clean compile quarkus:dev
- exception from above happens, does not start
Output of uname -a
or ver
MINGW64_NT-10.0-19045 NANBCHL9NG3 3.3.6-341.x86_64 2022-09-05 20:28 UTC x86_64 Msys
Output of java -version
openjdk 21.0.5 2024-10-15 LTS OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)
Quarkus version or git rev
3.17.6
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39) Maven home: C:\eclipse\tools\java\maven Java version: 21.0.5, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\21 Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Additional information
No response