It is OK to have @NumericField on the ID field of an indexed entity:
{code:java} @Indexed @Entity public class A {
@Id @GeneratedValue(strategy=GenerationType.AUTO) @NumericField @SortableField public Long getId() { return id; }
} {code}
This is working perfectly, the ID field is added as a numeric field to the index. But if I have an indexed entity that inherits its ID from a parent entity, it does not work anymore:
{code:java} @Indexed @Entity ... public abstract class A {
@Id @GeneratedValue(strategy=GenerationType.AUTO) @NumericField @SortableField public Long getId() { return id; } ... }
@Indexed @Entity ... public class B extends A { ... } {code}
Hibernate Search now fails with this error: org.hibernate.search.exception.SearchException: HSEARCH000262: @NumericField annotation is used on xxx.B#id without a matching @Field annotation at org.hibernate.search.engine.metadata.impl.NumericFieldsConfiguration.validate(NumericFieldsConfiguration.java:72)
There is no reason why this constellation should not be allowed, I think the only problem is that the numeric field validation does not take inherited ID fields of parent entities into account. |
|