0

私は、著者、書籍、カテゴリの3つのエンティティを持つSpring JPAプロジェクトを持っています。java - 休止状態の検索 - 作業を実行できません。エンティティクラスは@Indexされておらず、@ContainedInもホストされていません

インデックス用のHibernate Searchを使用したいと思います。 作成者クラスは@Indexedです。 Bookクラスには、@ContainedInで注釈が付けられたCategoryフィールドが含まれています。カテゴリは非常に単純なクラスです。

CLASS著者

@Entity 
@Table 
@Indexed 
public class Author extends ConcreteEntity { 

    private static final long serialVersionUID = 1L; 

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) 
    @IndexedEmbedded 
    private List<Book> books = new ArrayList<>(); 
} 

CLASSブック

@Entity 
@Table 
public class Book extends ConcreteEntity { 

    private static final long serialVersionUID = 1L; 

    @ContainedIn 
    private Category category; 
} 

CLASSカテゴリ

@Entity 
@Table 
public class Category extends ConceptEntity { 

    private static final long serialVersionUID = 1L; 
} 

CLASS ConcreteEntityとConceptEntity similarsです:

@MappedSuperclass 
public abstract class ConcreteEntity implements Serializable { 

    private static final long serialVersionUID = 1L; 

    @Id 
    @Column 
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO) 
    private String name; 

    @Column 
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO) 
    private String value; 
} 

@MappedSuperclass 
public abstract class ConceptEntity implements Serializable { 

    private static final long serialVersionUID = 1L; 

    @Id 
    @Column 
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO) 
    private String name; 

    @Column 
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO) 
    private String value; 
} 

Hibernate Searchを使用してリソースを保存する際にこの例外が発生しました。

org.hibernate.search.exception.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class test.hibernate.search.Category 

この問題の解決方法はわかりません。

ありがとうございました

答えて

1

予約が正しく設定されていません。 Hibernate Searchには、(カテゴリフィールドの@ContainedInアノテーションを使用して)カテゴリインデックスにブックが含まれていますが、カテゴリエンティティは@Indexedでマークされておらず、@ContainedInを介して別のインデックスにリンクされていません。

Hibernate Searchはあなたの設定があまり意味がないことを伝えるだけです。

モデルを考えると、代わりに@IndexedEmbeddedでカテゴリをマークしたかったと思います。

関連する問題