Package org.hibernate.search

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


    tx = fts.beginTransaction();
    for ( Entity2ForDoc0 e : (List<Entity2ForDoc0>) fts.createCriteria( Entity2ForDoc0.class ).list() ) {
      fts.delete( e );
    }
    for ( Entity1ForDoc0 e : (List<Entity1ForDoc0>) fts.createCriteria( Entity1ForDoc0.class ).list() ) {
      fts.delete( e );
    }
    tx.commit();
  }
View Full Code Here


    fts.clear();

    assertEquals( 0, fts.createFullTextQuery( new TermQuery( new Term("entity1.uid", String.valueOf( otherId ) ) ), Entity2ForUnindexed.class ).getResultSize() );

    tx = fts.beginTransaction();
    for ( Entity2ForUnindexed e : (List<Entity2ForUnindexed>) fts.createCriteria( Entity2ForUnindexed.class ).list() ) {
      fts.delete( e );
    }
    for ( Entity1ForUnindexed e : (List<Entity1ForUnindexed>) fts.createCriteria( Entity1ForUnindexed.class ).list() ) {
      fts.delete( e );
    }
View Full Code Here

    tx = fts.beginTransaction();
    for ( Entity2ForUnindexed e : (List<Entity2ForUnindexed>) fts.createCriteria( Entity2ForUnindexed.class ).list() ) {
      fts.delete( e );
    }
    for ( Entity1ForUnindexed e : (List<Entity1ForUnindexed>) fts.createCriteria( Entity1ForUnindexed.class ).list() ) {
      fts.delete( e );
    }
    tx.commit();

    fts.close();
View Full Code Here

    tx = s.beginTransaction();
    final QueryBuilder qb = s.getSearchFactory().buildQueryBuilder().forEntity( Husband.class ).get();
    Query query = qb.keyword().onField( "lastName" ).matching( "Roberto" ).createQuery();
    org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Husband.class );
    hibQuery.setProjection( FullTextQuery.THIS );
    Criteria fetchingStrategy = s.createCriteria( Husband.class );
    fetchingStrategy.setFetchMode( "spouse", FetchMode.JOIN );
    hibQuery.setCriteriaQuery( fetchingStrategy );

    resetFieldSelector();
    List result = hibQuery.list();
View Full Code Here

    s.close();

    //check non created object does get found!!1
    s = Search.getFullTextSession( openSession() );
    tx = s.beginTransaction();
    ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
      s.index( results.get( 0 ) );
      if ( index % 5 == 0 ) {
View Full Code Here

    s = Search.getFullTextSession( openSession() );
    tx = s.beginTransaction();
    parser = new QueryParser( TestConstants.getTargetLuceneVersion(), "id", TestConstants.stopAnalyzer );
    result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
    assertEquals( 0, result.size() );
    result = s.createCriteria( Email.class ).list();
    for ( int i = 0; i < loop / 2; i++ ) {
      s.index( result.get( i ) );
    }
    tx.commit(); //do the process
    s.index( result.get( loop / 2 ) ); //do the process out of tx
View Full Code Here

    s.close();

    //check non created object does get found!!1
    s = Search.getFullTextSession( openSession() );
    tx = s.beginTransaction();
    ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
      final Email o = (Email) results.get( 0 );
      s.index( o );
View Full Code Here

      s.clear();
    }

    Transaction tx = s.beginTransaction();
    // count of entities in database needs to be checked before SF is closed (HSQLDB will forget the entities)
    Number count = (Number) s.createCriteria( Clock.class )
        .setProjection( Projections.rowCount() )
        .uniqueResult();
    Assert.assertEquals( NUM_SAVED_ENTITIES, count.intValue() );
    tx.commit();
    s.close();
View Full Code Here

    fullTextSession.setCacheMode( CacheMode.IGNORE );

    Transaction transaction = fullTextSession.beginTransaction();

    int BATCH_SIZE = 10;
    ScrollableResults results = fullTextSession.createCriteria( Book.class )
        .setFetchSize( BATCH_SIZE )
        .scroll( ScrollMode.FORWARD_ONLY );
    int index = 0;
    while ( results.next() ) {
      index++;
View Full Code Here

    //cleanup
    music.getAuthors().clear();
    music2.getAuthors().clear();

    for ( Object o : s.createCriteria( Object.class ).list() ) {
      s.delete( o );
    }

    tx.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.