我是Hibernate搜索新手,有人可以建议我如何查询嵌入式实体(一对多)
@Indexed
@Entity
public class EventDetails implements Serializable
{
@OneToMany( cascade = CascadeType.ALL )
@IndexedEmbedded
@JoinColumn( name = "event_id" )
private Set<Batches> batches;
--setter and getter--
}
和
@Entity
@Indexed
public class Batches
{
@Column( name = "batch" )
private String batch;
@ManyToOne
@ContainedIn(mappedBy="batches")
private EventDetails eventDetails;
--setter and getter--
}
服务类
public List<EventDetails> search()
{
fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(getEntityManager());
QueryBuilder q = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(EventDetails.class).get();
org.apache.lucene.search.Query luceneQuery = q.keyword().wildcard().onField("").matching(text).createQuery();
javax.persistence.Query jpaQuery = fullTextEntityManager.createFullTextQuery(luceneQuery, EventDetails.class);
List<EventDetails> list = jpaQuery.getResultList();
return list;
}
现在如果我必须在批处理表中对“批处理”属性实现全文查询,我应该将什么作为参数传递给我的服务中的“onField()”方法?
谢谢!