@Override public ListPart<T> listPart(Long firstResult, Long maxResults) { if (noUniqueTerms) { return ListPart.newListPart(Collections.emptyList(), firstResult, maxResults, 0L, true); } FullTextQuery fullTextQuery = buildQuery(); applyPartialResults(fullTextQuery, firstResult, maxResults); @SuppressWarnings("unchecked") List<T> list = fullTextQuery.list(); return ListPart.newListPart(list, firstResult, maxResults, (long) fullTextQuery.getResultSize(), !fullTextQuery.hasPartialResults()); }
public ListPart<Object[]> listPartProjection(Long firstResult, Long maxResults, String... fields) { if (noUniqueTerms) { return ListPart.newListPart(Collections.emptyList(), firstResult, maxResults, 0L, true); } FullTextQuery fullTextQuery = buildQuery(); applyPartialResults(fullTextQuery, firstResult, maxResults); fullTextQuery.setProjection(fields); @SuppressWarnings("unchecked") List<Object[]> list = fullTextQuery.list(); return ListPart.newListPart(list, firstResult, maxResults, (long) fullTextQuery.getResultSize(), !fullTextQuery.hasPartialResults()); }
private void assertExecutionTimeoutOccursOnList() { FullTextQuery hibernateQuery = fts.createFullTextQuery( allSwatchClocksQuery, Clock.class ); hibernateQuery.limitExecutionTimeTo( 1, TimeUnit.NANOSECONDS ); List result = hibernateQuery.list(); System.out.println( "Result size early: " + result.size() ); assertEquals( "Test early failure, before the number of results are even fetched", 0, result.size() ); if ( result.size() == 0 ) { //sometimes, this assertTrue( hibernateQuery.hasPartialResults() ); } fts.clear(); }
@Test public void testEnoughTime() { Transaction tx = fts.beginTransaction(); FullTextQuery hibernateQuery = fts.createFullTextQuery( matchAllQuery, Clock.class ); hibernateQuery.setTimeout( 5, TimeUnit.MINUTES ); List results = hibernateQuery.list(); assertFalse( hibernateQuery.hasPartialResults() ); assertEquals( 1000, results.size() ); tx.commit(); }
private void assertExecutionTimeoutHasNoPartialResult() { FullTextQuery hibernateQuery = fts.createFullTextQuery( allSeikoClocksQuery, Clock.class ); hibernateQuery.limitExecutionTimeTo( 30, TimeUnit.SECONDS ); List results = hibernateQuery.list(); assertEquals( "Test below limit termination", 500, results.size() ); assertFalse( hibernateQuery.hasPartialResults() ); fts.clear(); }