Package org.hibernate.search

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


    projections.scroll( -5 );
    projection = projections.get();
    assertNull( projection );

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

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


    List<String> result = (List<String>) hibQuery.list();
    assertTrue( "incorrect transformation", result.get( 0 ).startsWith( "1000, Griffin, ITech" ) );
    assertTrue( "incorrect transformation", result.get( 1 ).startsWith( "1002, Jimenez, ITech" ) );

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

    assertEquals( "incorrect transformation", 1002, map.get( "id" ) );
    assertTrue( "incorrect transformation", map.get( FullTextQuery.DOCUMENT ) instanceof Document );
    assertEquals( "incorrect transformation", "1002", ( (Document) map.get( FullTextQuery.DOCUMENT ) ).get( "id" ) );

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

      assertEquals( "DOCUMENT size incorrect", 4, ( (Document) projection[6] ).getFields().size() );
    }
    assertEquals( "incorrect number of results returned", 4, counter );

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

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

    assertEquals( "last name incorrect", "Jackson", projection[6] );
    assertEquals( "dept incorrect", "Accounting", projection[7] );
    assertNotNull( "Lucene internal doc id", projection[8] );

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

  private void prepEmployeeIndex(FullTextSession s) {
View Full Code Here

    assertEquals( 1, result.size() );
    projection = (Object[]) result.get( 0 );
    assertEquals( "mainAuthor.name", null, projection[2] );

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

    projection = (Object[]) result.get( 0 );
    assertEquals( "mainAuthor.name", null, projection[2] );

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

View Full Code Here

    hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
    results = hibQuery.list();
    assertEquals("incorrect test record count", 1, results.size());
    assertEquals("incorrect test record", 2, ((Clock)results.get( 0 )).getId().intValue());

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

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

    query = parser.parse( "summary:Festina or summary:gloire" );
    hibQuery = s.createFullTextQuery( query, Clock.class, Book.class );
    results = hibQuery.list();
    assertEquals("incorrect class purged", 2, results.size());

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

  protected Class[] getMappings() {
View Full Code Here

    contact = (PersonalContact) s.get( PersonalContact.class, contact.getId() );
    contact.getPhoneNumbers().clear();
    contact.getAddresses().clear();
    s.flush();
    s.clear();
    s.createQuery( "delete " + Address.class.getName() ).executeUpdate();
    s.createQuery( "delete " + Phone.class.getName() ).executeUpdate();
    s.createQuery( "delete " + Contact.class.getName() ).executeUpdate();
    s.getTransaction().commit();

    s.close();
View Full Code Here

TOP
Copyright © 2018 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.