Examples of createFullTextQuery()


Examples of org.hibernate.Session.createFullTextQuery()

      FullTextSession session = Search.getFullTextSession( openSession() );
      QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEntity( Insurance.class ).get();
      Query luceneQuery = queryBuilder.keyword().wildcard().onField( "name" ).matching( "ins*" ).createQuery();
      Transaction transaction = session.beginTransaction();
      @SuppressWarnings("unchecked")
      List<Insurance> list = session.createFullTextQuery( luceneQuery ).list();
      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getName() ).isEqualTo( "Insurance Corporation" );
      transaction.commit();
      session.clear();
      session.close();
View Full Code Here

Examples of org.hibernate.Session.createFullTextQuery()

      FullTextSession session = Search.getFullTextSession( openSession() );
      QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEntity( IndexedNews.class ).get();
      Query luceneQuery = queryBuilder.keyword().wildcard().onField( "newsId" ).ignoreFieldBridge().matching( "tit*" ).createQuery();
      Transaction transaction = session.beginTransaction();
      @SuppressWarnings("unchecked")
      List<IndexedNews> list = session.createFullTextQuery( luceneQuery ).list();
      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getContent() ).isEqualTo( "content" );
      assertThat( list.get( 0 ).getNewsId().getTitle() ).isEqualTo( "title" );
      assertThat( list.get( 0 ).getNewsId().getAuthor() ).isEqualTo( "author" );
      transaction.commit();
View Full Code Here

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

    final QueryBuilder b = fts.getSearchFactory()
        .buildQueryBuilder()
        .forEntity( Insurance.class )
        .get();
    final Query lq = b.keyword().onField( "name" ).matching( "Macif" ).createQuery();
    final FullTextQuery ftQuery = fts.createFullTextQuery( lq, Insurance.class );
    ftQuery.initializeObjectsWith( ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID );
    final List<Insurance> resultList = ftQuery.list();
    assertThat( resultList ).hasSize( 1 );
    for ( Object e : resultList ) {
      fts.delete( e );
View Full Code Here

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

    final QueryBuilder b = ftSession.getSearchFactory()
        .buildQueryBuilder()
        .forEntity( Insurance.class )
        .get();
    final Query lq = b.keyword().onField( "name" ).matching( "Macif" ).createQuery();
    final org.hibernate.search.FullTextQuery ftQuery = ftSession.createFullTextQuery( lq, Insurance.class );
    ftQuery.initializeObjectsWith( ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID );
    final List<Insurance> resultList = ftQuery.list();
    assertThat( getFactory().getPersistenceUnitUtil().isLoaded( resultList.get( 0 ) ) ).isTrue();
    assertThat( resultList ).hasSize( 1 );
    for ( Object e : resultList ) {
View Full Code Here

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

      FullTextSession session = Search.getFullTextSession( openSession() );
      QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEntity( Insurance.class ).get();
      Query luceneQuery = queryBuilder.keyword().wildcard().onField( "name" ).matching( "ins*" ).createQuery();
      Transaction transaction = session.beginTransaction();
      @SuppressWarnings("unchecked")
      List<Insurance> list = session.createFullTextQuery( luceneQuery ).list();
      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getName() ).isEqualTo( "Insurance Corporation" );
      transaction.commit();
      session.clear();
      session.close();
View Full Code Here

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

      FullTextSession session = Search.getFullTextSession( openSession() );
      QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEntity( IndexedNews.class ).get();
      Query luceneQuery = queryBuilder.keyword().wildcard().onField( "newsId" ).ignoreFieldBridge().matching( "tit*" ).createQuery();
      Transaction transaction = session.beginTransaction();
      @SuppressWarnings("unchecked")
      List<IndexedNews> list = session.createFullTextQuery( luceneQuery ).list();
      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getContent() ).isEqualTo( "content" );
      assertThat( list.get( 0 ).getNewsId().getTitle() ).isEqualTo( "title" );
      assertThat( list.get( 0 ).getNewsId().getAuthor() ).isEqualTo( "author" );
      transaction.commit();
View Full Code Here

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

  public List<?> list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException {
    FullTextSession fullTextSession = Search.getFullTextSession( (Session) session );

    LuceneQueryParsingResult parsingResult = getLuceneQuery( queryParameters, fullTextSession );

    FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( parsingResult.getQuery(), parsingResult.getTargetEntity() );

    if ( requiresProjections( parsingResult.getProjections() ) ) {
      fullTextQuery.setProjection( parsingResult.getProjections().toArray( new String[parsingResult.getProjections().size()] ) );
    }
View Full Code Here

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

  }

  @Override
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities) {
    FullTextSession ftSession = getFullTextSession();
    return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
  }

  @Override
  public <T> void index(T entity) {
    getFullTextSession().index( entity );
View Full Code Here

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

  }

  @Override
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<?>... entities) {
    FullTextSession ftSession = getFullTextSession();
    return new FullTextQueryImpl( ftSession.createFullTextQuery( luceneQuery, entities ), ftSession );
  }

  @Override
  public <T> void index(T entity) {
    getFullTextSession().index( entity );
View Full Code Here

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

        try {
            qry = HibernateSearchTools.generateQuery(searchTerm, this.persistentClass, sess, defaultAnalyzer);
        } catch (ParseException ex) {
            throw new SearchException(ex);
        }
        org.hibernate.search.FullTextQuery hibQuery = txtSession.createFullTextQuery(qry,
                this.persistentClass);
        return hibQuery.list();
    }

    /**
 
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.