[hibernate-dev] [SEARCH] @Indexed on abstract classes

Emmanuel Bernard emmanuel at hibernate.org
Sat May 12 04:51:10 EDT 2012


On 10 mai 2012, at 08:49, Guillaume Smet wrote:

> Hi Search team,
> 
> I have this question for a long time but, this time, having 30 (and
> growing) indexed entities inheriting from an abstract class, I thought
> I might as well ask about it...
> 
> Is there any reason why we can't set the @Indexed annotation on the
> abstract class to get all the implementations indexed in their
> separate indexes? This way, I wouldn't have to put the annotation on
> each implementation and think about adding it each time I extend this
> abstract class.

That would go counter to the JPA design I think and to be honest, I like the idea of being able to not index a given branch of a class hierarchy.
But more importantly, you would require Hibernate Search to scan for all subclasses in the classpath and I don't want to go anywhere near that.

> 
> Another painful things that beats me yesterday is that I cannot do:
> searchFactory.buildQueryBuilder().forEntity(MyAbstractEntity.class).get();
> to build Lucene queries based on the common indexed fields of the
> abstract class: I'm forced to use one of the concrete implementation
> (and apart that it's not that nice, I'm not that confident I can
> choose one that will never be removed from the code base).

Scratch your own :) itch https://hibernate.onjira.com/browse/HSEARCH-703
This is an issue that has been opened for a while but not addressed by like of motivated contributors. The solution is fairly simple at first sight.


More information about the hibernate-dev mailing list