Package org.hibernate.search

Examples of org.hibernate.search.FullTextQuery.list()


  public void testDefaultLookupMethod() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "CriteriaObjectInitializer should have been used as object initializer",
          1,
View Full Code Here


  public void testSetLookupMethodPersistenceContextUpperCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( "PERSISTENCE_CONTEXT", null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "PersistenceContextObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

  public void testSetLookupMethodPersistenceContextLowerCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( "persistence_context", null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "PersistenceContextObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

  public void testSetDatabaseRetrievalMethodUpperCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, "FIND_BY_ID" ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "LookupObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

  public void testSetDatabaseRetrievalMethodLoweCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, "find_by_id" ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "LookupObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

        .buildQueryBuilder()
        .forEntity( FormulaAdd.class )
        .get();
    Query luceneQuery = queryBuilder.keyword().onField( "aplusB" ).ignoreAnalyzer().matching( value ).createQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, FormulaAdd.class );
    List resultsList = query.list();
    transaction.commit();
    Assert.assertEquals( 1, resultsList.size() );
    FormulaAdd result = (FormulaAdd) resultsList.get( 0 );
    Assert.assertEquals( value, result.getAplusB() );
  }
View Full Code Here

    FullTextQuery query = queryHondaWithFacet( request );

    assertTrue( "We should have facet results", query.getFacetManager().getFacets( facetName ).size() > 0 );

    query.getFacetManager().disableFaceting( facetName );
    query.list();

    assertTrue( "We should have no facets", query.getFacetManager().getFacets( facetName ).size() == 0 );
  }

  @Test
View Full Code Here

    // and now check also for the real index contents:
    Query query = NumericFieldUtils.createNumericRangeQuery( "overriddenFieldName", 1, 6, true, true );
    FullTextQuery fullTextQuery = fullTextSession
        .createFullTextQuery( query, Location.class )
        .setProjection( ProjectionConstants.DOCUMENT );
    assertEquals( "Check for deletion on index projection", 0, fullTextQuery.list().size() );

    tx.commit();
  }

  @TestForIssue(jiraKey = "HSEARCH-1193")
View Full Code Here

    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( TestConstants.getTargetLuceneVersion(), "name", TestConstants.standardAnalyzer );
    Query query = parser.parse( "name:foo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query );
    try {
      hibQuery.list();
      fail();
    }
    catch (SearchException e) {
      assertTrue( "Wrong message", e.getMessage().startsWith( "There are no mapped entities" ) );
    }
View Full Code Here

  private int countBooksInIndex() {
    Session session = openSession();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    fullTextSession.beginTransaction();
    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
    int size = fullTextQuery.list().size();
    fullTextSession.getTransaction().commit();
    fullTextSession.close();
    return size;
  }
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.