4

How can can I combine hibernate criteria API with Lucene hibernate search?

org.hibernate.Criteria criteria = session.createCriteria(class);

criteria.add(Restrictions.ne(property, value));

FullTextQuery fullTextQuery = ftm.createFullTextQuery(booleanQuery, class);

fullTextQuery.setCriteriaQuery(criteria);

Object result = fullTextQuery.getResultList();

In the above example hibernate isn't respecting the restrictions?

Sanne
  • 6,027
  • 19
  • 34
  • Can anyone please check this link http://stackoverflow.com/questions/11776214/lucene-hibernate-full-text-search – jose Aug 06 '12 at 06:03

2 Answers2

2

According to the documentation no where restriction can be defined in the criteria set in FullTextQuery. As you are using a BooleanQuery, you can add to it a clause with the restriction.

Community
  • 1
  • 1
0

Aren't you using a wrong instance of Criteria? You add a restriction to criteria, but use the hibernateCriteria on other places

Montolide
  • 773
  • 3
  • 12
  • 27