Package org.hibernate.search

Examples of org.hibernate.search.FullTextSession.createQuery()


            String query = "select o from " + entityClass.getName() + " o fetch all properties";
            if (WikiNode.class.isAssignableFrom(entityClass)) {
                // If it's a WikiNode, fetch the associated User instances, avoiding N+1 selects
                query = "select o from " + entityClass.getName() + " o inner join fetch o.createdBy left join fetch o.lastModifiedBy fetch all properties";
            }
            ScrollableResults cursor = ftSession.createQuery(query).scroll();

            cursor.last();
            int count = cursor.getRowNumber() + 1;
            log.debug("total documents in database: " + count);
View Full Code Here


      int[] termPositions = vector.getTermPositions(0);
      assertEquals(0, termPositions[0]);
      assertEquals(3, termPositions[1]);

      //cleanup
      for (Object element : s.createQuery("from " + Employee.class.getName()).list()) s.delete(element);
      tx.commit();
      s.close();
   }

View Full Code Here

      TermPositionVector vector = (TermPositionVector) reader.getTermFreqVector(0, "dept");
      assertNull("should not find a term position vector", vector);

      //cleanup
      for (Object element : s.createQuery("from " + ElectricalProperties.class.getName()).list())
         s.delete(element);
      tx.commit();
      s.close();
   }
View Full Code Here

        "incorrect document returned",
        ( ( BoostedGetDescriptionLibrary ) results.get( 0 ) ).getDescription().startsWith( "Martians" )
    );

    //cleanup
    for ( Object element : fullTextSession.createQuery( "from " + BoostedGetDescriptionLibrary.class.getName() )
        .list() ) {
      fullTextSession.delete( element );
    }
    tx.commit();
    fullTextSession.close();
View Full Code Here

    //System.out.println( hibQuery.explain( 0 ) );
    //System.out.println( hibQuery.explain( 1 ) );

    //cleanup
    for ( Object element : fullTextSession.createQuery( "from " + BoostedFieldDescriptionLibrary.class.getName() )
        .list() ) {
      fullTextSession.delete( element );
    }
    tx.commit();
    fullTextSession.close();
View Full Code Here

        "incorrect document returned",
        ( ( BoostedDescriptionLibrary ) results.get( 0 ) ).getDescription().startsWith( "Martians" )
    );

    //cleanup
    for ( Object element : fullTextSession.createQuery( "from " + BoostedDescriptionLibrary.class.getName() )
        .list() ) {
      fullTextSession.delete( element );
    }
    tx.commit();
    fullTextSession.close();
View Full Code Here

    hibQuery = s.createFullTextQuery( query );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Query with delete objects", 0, result.size() );

    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
    s.close();
  }

  public void testResultSize() throws Exception {
View Full Code Here

    hibQuery = s.createFullTextQuery( query );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "2 entities should be loaded", 2, stats.getEntityLoadCount() );
    if ( !enabled ) stats.setStatisticsEnabled( false );
    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
    s.close();
  }

  public void testFirstMax() throws Exception {
View Full Code Here

    hibQuery.setMaxResults( 3 );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "first result out of limit", 0, result.size() );

    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
    s.close();
  }

  public void testIterator() throws Exception {
View Full Code Here

    hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
    result = hibQuery.iterate();
    assertNotNull( result );
    assertFalse( result.hasNext() );

    for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
    tx.commit();
    s.close();
  }

  public void testScrollableResultSet() throws Exception {
View Full Code Here

TOP
Copyright © 2015 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.