Log a warning or throw an error for Hibernate Search annotations in the wrong place

Description

Currently if we annotate a method whose name, arguments, or modifiers (static) do not match the definition of a JavaBean getter, the annotation will simply be ignored.

Same if someone adds @Indexed on a class that is not a Hibernate ORM entity and is not otherwise referenced in the Hibernate Search model.

We should consider logging a warning or throwing an exception instead. Probably warn for now and throw an exception in Hibernate Search 7.

See https://discourse.hibernate.org/t/suggestion-raise-an-exception-when-hsearch-annotation-is-present-on-unrecognized-method/5769

Activity

Yoann RodièreJune 21, 2022 at 7:34 AM

Note this will most likely require https://hibernate.atlassian.net/browse/HSEARCH-1213

Yoann RodièreJune 21, 2022 at 7:30 AM

Related: we don’t warn/fail when someone adds @Indexed to a class that is not a Hibernate ORM entity, unless it is somehow referenced somewhere in the Hibernate Search model (@IndexedEmbedded from an actual @Indexed entity, for example).

See https://stackoverflow.com/q/72692676/6692043

Details

Assignee

Reporter

Priority

Created October 12, 2021 at 3:52 PM
Updated September 25, 2023 at 2:48 PM