Ich habe ein Spring JPA-Projekt mit 3 Entitäten: Autor, Buch und Kategorie.Java - Hibernate Search - Kann keine Arbeit ausführen. Entity Class ist nicht @Indexed noch Hosts @ContainedIn
Ich möchte Hibernate Search für Indizes verwenden. Autorenklasse ist @Indexed; Die Buchklasse enthält ein Kategorienfeld, das mit @ContainedIn gekennzeichnet ist. Kategorie ist eine sehr einfache Klasse.
CLASS Autor
@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 Buch
@Entity
@Table
public class Book extends ConcreteEntity {
private static final long serialVersionUID = 1L;
@ContainedIn
private Category category;
}
CLASS-Kategorie
@Entity
@Table
public class Category extends ConceptEntity {
private static final long serialVersionUID = 1L;
}
CLASS ConcreteEntity und ConceptEntity sind 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;
}
Ich habe diese Ausnahme beim Speichern einer Ressource mit Hibernate Search.
org.hibernate.search.exception.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class test.hibernate.search.Category
Ich verstehe nicht, wie Sie dieses Problem lösen.
Danke