I have an object called MyItemBean
which can have 0 or more associated KeywordBean
objects. The resulting classes look like this:
@Entity
public class MyItemBean {
...stuff...
@ManyToMany(targetEntity = KeywordBean.class, cascade = CascadeType.PERSIST)
@JoinTable(name = "tbl_item_keyword", joinColumns = @JoinColumn(name = "item_id"), inverseJoinColumns = @JoinColumn(name = "keyword_id"))
private List<KeywordBean> keywords = null;
...more stuff...
}
@Entity
public class KeywordBean {
...stuff...
private String value=null;
...more stuff...
}
I'm using JBoss Seam/Hibernate Search to index these objects so I can perform search queries against them. I'd like to be able to search for MyItemBean
instances with a given keyword value. This relation, however, is unidirectional because I apply KeywordBean
objects to more than just MyItemBean
. I've looked in the Hibernate Search documentation for examples on how to index relations, but all of the examples they provide are bi-directional. Can anyone tell me what annotations I need to apply on MyItemBean.keywords
to index the keyword values properly?