Annotation processor or Maven/Gradle plugins for static metamodel generation

Description

Follows up on https://hibernate.atlassian.net/browse/HSEARCH-3319 : once the Hibernate Search DSL supports type-safe field references, we could start working on a tool to generate a static metamodel that can be used with the DSL.

Activity

Marko BekhtaSeptember 5, 2024 at 6:56 AM

Yup, I think you’ve summarised this nicely, and there's not much to add. Thanks !

Yoann RodièreSeptember 5, 2024 at 6:48 AM

We discussed this on Zulip: https://hibernate.zulipchat.com/#narrow/stream/132092-hibernate-search-dev/topic/Static.20metamodel.20HSEARCH-4951

Key takeaways:

  1. Since the static metamodel may be referenced in the same Java project where it’s generated, we must generate it before, or during, compilation – otherwise compilation would fail.
    Thus, Maven/Gradle plugins are unlikely solutions: we need a javac annotation processor.

  2. In the annotation processor, execution of application code is impossible.
    Thus, when application developers expect a static metamodel, we cannot support programmatic mapping, binders and things like PropertyMappingAnnotationProcessor as they are: we need new solutions to replace them.

  3. In the annotation processor, CDI is unavailable.
    Thus, when users expect a static metamodel, we cannot support CDI instantiation of binders: application developers will need to rely on reflection-based instantiation for these components.

  4. In the annotation processor, access to Hibernate ORM’s Metadata objects is impossible: https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/Hibernate.20Models.20and.20Annotation.20Processors
    Thus, we need another way of inferring the Hibernate ORM metadata we need (there isn’t much).

I think that’s the gist of it – feel free to add anything I forgot 🙂

Details

Assignee

Reporter

Components

Fix versions

Priority

Created September 18, 2023 at 2:41 PM
Updated October 1, 2024 at 11:06 AM

Flag notifications