Package org.hibernate.search.jpa

Examples of org.hibernate.search.jpa.FullTextEntityManager.clear()


      Clock clock = new Clock( Long.valueOf( i ), "Model cat A" + i, ( i % 2 == 0 ) ? "Seiko" : "Swatch", Long.valueOf( 2000 + i ) );
      em.persist( clock );
    }
    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    Query query = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    FullTextQuery hibernateQuery = em.createFullTextQuery( query, Clock.class );
View Full Code Here


    }
    catch (Exception e) {
      fail( "Expected a QueryTimeoutException" );
    }
    em.getTransaction().commit();
    em.clear();

    em.getTransaction().begin();
    assertEquals( 1000, em.createQuery( "delete from " + Clock.class.getName() ).executeUpdate() );
    em.getTransaction().commit();
View Full Code Here

      Clock clock = new Clock( Long.valueOf( i ), "Model cat A" + i, ( i % 2 == 0 ) ? "Seiko" : "Swatch", Long.valueOf( 2000 + i ) );
      em.persist( clock );
    }
    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    Query query = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    FullTextQuery hibernateQuery = em.createFullTextQuery( query, Clock.class );
View Full Code Here

    Query query = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    FullTextQuery hibernateQuery = em.createFullTextQuery( query, Clock.class );
    List results = hibernateQuery.getResultList();
    assertEquals( 500, results.size() );

    em.clear();

    query = builder.keyword().onField( "brand" ).matching( "Swatch" ).createQuery();
    hibernateQuery = em.createFullTextQuery( query, Clock.class );
    hibernateQuery.limitExecutionTimeTo( 1, TimeUnit.NANOSECONDS );
    List result = hibernateQuery.getResultList();
View Full Code Here

    if ( result.size() == 0 ) {
      //sometimes, this
      assertTrue( hibernateQuery.hasPartialResults() );
    }

    em.clear();

    //We cannot test intermediate limit, Lucene / hibernate: too unpredictable

//    hibernateQuery = fts.createFullTextQuery( query, Clock.class );
//    hibernateQuery.limitFetchingTime( 1000, TimeUnit.NANOSECONDS );
View Full Code Here

    assertEquals( "Test below limit termination", 500, results.size() );
    assertFalse( hibernateQuery.hasPartialResults() );

    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
    assertEquals( 1000, em.createQuery( "delete from " + Clock.class.getName() ).executeUpdate() );
    em.getTransaction().commit();
View Full Code Here

    FullTextEntityManager em = Search.getFullTextEntityManager( factory.createEntityManager() );
    em.getTransaction().begin();
    Bretzel bretzel = new Bretzel( 23, 34 );
    em.persist( bretzel );
    em.getTransaction().commit();
    em.clear();

    // verify against index
    assertEquals( 1, countBretzelsViaIndex( em ) );
    em.purgeAll( Bretzel.class );
View Full Code Here

    FullTextEntityManager em = Search.getFullTextEntityManager( factory.createEntityManager() );
    em.getTransaction().begin();
    Bretzel bretzel = new Bretzel( 23, 34 );
    em.persist( bretzel );
    em.getTransaction().commit();
    em.clear();
    em.getTransaction().begin();
    QueryParser parser = new QueryParser( getTargetLuceneVersion(), "title", TestConstants.stopAnalyzer );
    Query query = parser.parse( "saltQty:noword" );
    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term( "saltQty", "23" ) );
View Full Code Here

        ( (Bretzel) em.createFullTextQuery( query ).getSingleResult() ).getSaltQty()
    );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
    em.remove( em.find( Bretzel.class, bretzel.getId() ) );
    em.getTransaction().commit();
    em.close();
View Full Code Here

    FullTextEntityManager em = Search.getFullTextEntityManager( factory.createEntityManager() );
    em.getTransaction().begin();
    Bretzel bretzel = new Bretzel( 23, 34 );
    em.persist( bretzel );
    em.getTransaction().commit();
    em.clear();

    //Not really a unit test but a test that shows the method call without failing
    //FIXME port the index test
    em.getTransaction().begin();
    em.index( em.find( Bretzel.class, bretzel.getId() ) );
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.