0

我有一个关于 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 放在子类上,但这会产生相同的错误。

4

1 回答 1

1

@Indexed注释确实应该在子类上。但是,我不确定这与鉴别器列有什么关系。JPA 和 Search 注释应该是正交的。真的是两种不同的东西。顺便说一句,您的语言实体如何?另见https://forum.hibernate.org/viewtopic.php?f=9&t=993097&hilit=abstract+base+class

于 2013-02-07T10:52:46.513 回答