I have a Spring JPA project with 3 entities: Author, Book and Category.
I want to use Hibernate Search for indexes. Author class is @Indexed; Book class contains a Category field annotated with @ContainedIn; Category is a very simple class.
CLASS Author
@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 Book
@Entity
@Table
public class Book extends ConcreteEntity {
private static final long serialVersionUID = 1L;
@ContainedIn
private Category category;
}
CLASS Category
@Entity
@Table
public class Category extends ConceptEntity {
private static final long serialVersionUID = 1L;
}
CLASS ConcreteEntity and ConceptEntity are 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;
}
I've got this exception while saving a resource using Hibernate Search.
org.hibernate.search.exception.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class test.hibernate.search.Category
I don't understand how to solve this issue.
Thanks