3

Hibernate search (lucene) has an issue: If you apply a criteria restriction to FullTextQuery and apply pagination restrictions, i.e. criteria.setMaxResults() and criteria.setFirstResult(), the fullTextQuery.getResultSize() returns a count which doesn't include the criteria restriction.

HSEARCH-753 acknoweldges this issue and resolves it (only so far as a warning exception is thrown)

Could anyone offer suggestions on how I may work around this issue?

jaseFace
  • 1,415
  • 5
  • 22
  • 34

2 Answers2

0

Oddly, all I've needed to do to fix this is to re-order the code so that the call to fullTextQuery.getResultSize() is before the call to fullTextQuery.list();

Which I hesitate to even mention since it feels a little too "Voodoo" - but it's certainly working...

RedYeti
  • 1,024
  • 14
  • 28
-2

I used Hibernate Query for paging purpose it supported. checkh the below code for more details

final Query query = session.createQuery(getSession().getNamedQuery("Your query");

query.setMaxResults(20); query.setFirstResult(10);

  • 1
    Thanks but it's a hibernate search (lucene) issue I'm facing. Please check out the above link regarding the exception catching. :-) – jaseFace Oct 28 '11 at 22:57