I have a country table which is mapped to the Country entity using JPA.I am trying to query it using FullTextQuery. However it is returning a List containing only null values. The table has 172 rows, the query return 174 nulls.
What could be the problem ?
Information :
I had done manual indexing using MassIndexer above this code but i removed it after executing it once.The indexes are getting set properly,as the files are getting created and they are 7Kb so obviously contain something. I am using Hibernate Search with JPA and I have used CDI to inject the entity manager
Other stuff : using eclipse, JBoss,maven and I have locally installed hibernate-search-orm-4.1.1.Final.
I am not getting any errors/warnings.
The country table has a composite key which is inherited from another entity. The composite key consists of id and date field.I have written a two way string bridge field and specified that in the base class. The code for that is at the bottom, I have ignored the date field temporarily for simplicity purpose.
Please Help,
THanks in Advance.
Code:
if (searchString.isEmpty())
return null;
if (entityManager == null)
throw new RuntimeException("Entity Manager Not initialised");
FullTextEntityManager fullTextEntityManager = Search
.getFullTextEntityManager(entityManager);
final QueryBuilder queryBuilder = fullTextEntityManager
.getSearchFactory().buildQueryBuilder()
.forEntity(Country.class).get();
org.apache.lucene.search.Query luceneQuery = queryBuilder.all().createQuery();
javax.persistence.Query fullTextQuery = fullTextEntityManager
.createFullTextQuery(luceneQuery);
List<Country> list = fullTextQuery.getResultList();
CompositePKBridge:
Code:
public class CompositePKBridge implements TwoWayStringBridge {
@Override
public String objectToString(Object arg0) {
CompositePK compositePK = (CompositePK)arg0;
return compositePK.getId() + "";
}
@Override
public Object stringToObject(String value) {
CompositePK compositePK=new CompositePK();
compositePK.setId(Long.parseLong(value));
return compositePK;
}
}