i am using hibernate search in my project,i have two tables one is CatalogueBase and another one is CatalogueCopyDetails (this table have one foreign key that referring CatalogueBase table). Now i wanted to involve two tables in searching
this my DAO Class it's working fine and it used to search CatalogueBase how can i add another table for this
private List<CatalogueBase> searchTitle(String queryString) throws InterruptedException { Session session = getSession(); FullTextSession fullTextSession = Search.getFullTextSession(session); fullTextSession.createIndexer().startAndWait(); QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity(CatalogueBase.class).get(); org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword().onFields("title","subTitle","callnumber","classnumber","volume","noofcopies").matching(queryString).createQuery(); org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, CatalogueBase.class); List<CatalogueBase> contactList = fullTextQuery.list(); return contactList; }
@Override public List<CatalogueBase> getSearchDao(String search) throws InterruptedException { List<CatalogueBase> result = searchTitle(search); return result; } This is my POJO Class of CatalogueBase
@Indexed @JsonAutoDetect @Entity @Table(name="catalogueBase") public class CatalogueBase extends BaseObject implements Serializable {
private Long id; private String title; private String titleNumber;
@Id @GeneratedValue @Column(name="id") public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) @Column(name = "title", nullable = false, length = 150) public String getTitle() { return this.title; }
public void setTitle(String title) { this.title = title; } ....... This is CtalogueCopyDetails class
@Indexed @JsonAutoDetect @Entity @Table(name="cataloguecopydetails") public class CatalogueCopyDetails extends BaseObject implements Serializable {
private Long id; private CatalogueBase catalogueBase;
@Id @GeneratedValue @Column(name="id") public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
@ManyToOne @JoinColumn(name="cataloguebaseid" , insertable=true, updatable=true,nullable=true) public CatalogueBase getCatalogueBase() { return catalogueBase; } public void setCatalogueBase(CatalogueBase catalogueBase) { this.catalogueBase = catalogueBase; }[/color]
|