我有一个关于Hibernate Search映射和使用抽象基类的问题。 我收到以下错误
Caused by: org.hibernate.search.SearchException: Found invalid @IndexedEmbedded->paths configured on class nl.project.model.social.AbstractGroup, member language: language.id
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.validateAllPathsEncountered(AbstractDocumentBuilder.java:901)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.checkForIndexedEmbedded(AbstractDocumentBuilder.java:880)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeMemberLevelAnnotations(AbstractDocumentBuilder.java:489)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:391)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.<init>(AbstractDocumentBuilder.java:174)
at org.hibernate.search.engine.spi.DocumentBuilderContainedEntity.<init>(DocumentBuilderContainedEntity.java:60)
at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:396)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:222)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:146)
at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:130)
at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:83)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:301)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
基于以下映射配置
@Entity
@Table
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DTYPE", discriminatorType= DiscriminatorType.STRING, length = 3)
@Indexed
public abstract class AbstractGroup implements Serializable, IEntity, IPhoto{
protected Language language;
@ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(name="FK_LanguageId")
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region=CacheRegion.NEVERCHANGE)
@NotNull
@IndexedEmbedded(includePaths={"id"})
public Language getLanguage() {
return language;
}
}
@Entity
@DiscriminatorValue(value = "GRP")
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region=CacheRegion.GROUP)
public class Group extends AbstractGroup{
@Entity
@DiscriminatorValue(value = "PGE")
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region=CacheRegion.GROUP)
public class Page extends AbstractGroup{
我已经尝试将@Indexed放在子类上,但这会产生相同的错误。
答案 0 :(得分:1)
@Indexed 注释应该确实在子类上。但是,我不确定这应该与te鉴别器列有什么关系。 JPA和搜索注释应该是正交的。真的有两件事。顺便问一下,你的 Language 实体是怎样的?另请参阅https://forum.hibernate.org/viewtopic.php?f=9&t=993097&hilit=abstract+base+class