Example #1
0
 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();
 }
Example #2
0
 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();
 }
Example #3
0
  @Override
  public ListPart<T> listPart(Long firstResult, Long maxResults) {
    applyPartialResults(fullTextQuery, firstResult, maxResults);

    @SuppressWarnings("unchecked")
    List<T> list = fullTextQuery.list();

    return ListPart.newListPart(
        list,
        firstResult,
        maxResults,
        Long.valueOf(fullTextQuery.getResultSize()),
        !fullTextQuery.hasPartialResults());
  }
Example #4
0
  @SkipForDialect(
      value = PostgreSQLDialect.class,
      jiraKey = "JBPAPP-2945",
      comment = "PostgreSQL driver does not implement query timeout")
  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();
  }
Example #5
0
  public ListPart<Object> listPartProjection(Long firstResult, Long maxResults, String... fields) {
    applyPartialResults(fullTextQuery, firstResult, maxResults);

    fullTextQuery.setProjection(fields);

    @SuppressWarnings("unchecked")
    List<Object> list = fullTextQuery.list();

    return ListPart.newListPart(
        list,
        firstResult,
        maxResults,
        Long.valueOf(fullTextQuery.getResultSize()),
        !fullTextQuery.hasPartialResults());
  }