Skip to content

Commit

Permalink
Merge pull request #45506 from yrodiere/i45503
Browse files Browse the repository at this point in the history
Register JPA static metamodel classes for reflection
  • Loading branch information
gsmet authored Jan 13, 2025
2 parents 18c4016 + dae62d2 commit 234fdd8
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public JpaModelBuildItem discoverModelAndRegisterForReflection() throws BuildExc
managedClassNames.addAll(collector.modelTypes);
for (String className : managedClassNames) {
reflectiveClass.produce(ReflectiveClassBuildItem.builder(className).methods().fields().build());
// Register static metamodel classes as well, so that their `class_` attribute can be populated.
// See org.hibernate.metamodel.internal.MetadataContext.populateStaticMetamodel
// Note: registering classes that do not exist is not a problem -- and is necessary if the application
// tries to access these classes via reflection anyway (which it will, through Hibernate ORM).
reflectiveClass.produce(ReflectiveClassBuildItem.builder(className + "_").fields().build());
}

if (!collector.enumTypes.isEmpty()) {
Expand Down

0 comments on commit 234fdd8

Please sign in to comment.