-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate with lucene search for more than one table
PostPosted: Mon Aug 12, 2013 5:53 am 
Newbie

Joined: Tue May 07, 2013 1:07 am
Posts: 2
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.