Hibernate Search: Inheritance Models

hibernate, hibernate-search, orm

Solution

The JPA inheritance model does not play a role for Hibernate Search and as the previous answer indicated it is even the default.

On the other hand the Lucene document is a flat structure, basically a map of field names to valuaes. On top of the fields you are indexing, Hibernate Search adds the unique primary key of the entity and its class name. The latter is used when you limit your search to a certain class(es).

Problem

Im planning to use Hibernate Search for fulltext search on my models and im concerened whether I can continue to use `InheritanceType.SINGLE_TABLE` for my model hierachy or whether I have to manually create one big flat model. Basically I have two requieremnts: - Being able to perform a search on all submodels of a concrete model in the hierachy - Being able to perform a search both on common fields of basemodels and fields of the concrete submodel Unfortunately the reference doesnt says anything about inheritance but just about embedded and associated objects.

Original source