Hi! i try to use hibernate search and have some troubles. Help me please.
I 've got two entities: File and Category. The File can belong to several categories. Categories have some hierarchy.
Code:
@Entity
@Indexed
@Table(name = "file")
public class File implements BusinessEntity {
........
@ManyToMany (cascade = {CascadeType.PERSIST})
@JoinTable(
name = "file_category",
joinColumns = {@JoinColumn(name = "file_id", nullable = false)},
inverseJoinColumns = {@JoinColumn(name = "category_id", nullable = false)}
)
@LazyCollection(LazyCollectionOption.FALSE)
@Cascade(
org.hibernate.annotations.CascadeType.PERSIST
)
@IndexedEmbedded
public List<Category> getCategories() {
return categories;
}
Code:
@Entity
@Table(name = "cpa_category")
@Indexed
public class Category implements BusinessEntity {
...............
@OneToMany (mappedBy = "parent", cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
public List<Category> getChildrens() {
return childrens;
}
Now i can search by concrete categories id, but i want search by parent category id.
For example;
- Programming
- Java
- Swing
- AWT
And file in AWT category. So by AWT id i can find the file, but what if i need to search by Programming id and find all files of all children categories?
Thank you!