Package org.hibernate.search

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


   @SuppressWarnings("unchecked")
   private void indexProducts()
   {
       FullTextSession fullTextSession = getFullTextSession();
       List results = fullTextSession.createCriteria(Product.class)
            .setFetchMode("actors", FetchMode.JOIN)
            .setFetchMode("categories", FetchMode.JOIN)
            .list();
      for (Object obj : results)
      {
View Full Code Here


   private void indexAllClasses(Class... entityTypes)
   {
      FullTextSession fullTextSession = getFullTextSession();
      for (Class entityType : entityTypes)
      {
         for (Object obj : fullTextSession.createCriteria(entityType).list())
         {
            fullTextSession.index(obj);
         }
      }
   }
View Full Code Here

        em = emf.createEntityManager();
    }

    private void index() {
        FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
        List results = ftSession.createCriteria(Book.class).list();
        for (Object obj : results) {
            ftSession.index(obj);
        }
    ftSession.flushToIndexes();
    }
View Full Code Here

    assertEquals( "Query with no explicit criteria", 1, result.size() );
    book = (Book) result.get( 0 );
    assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );

    result = s.createFullTextQuery( query ).setCriteriaQuery(
        s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN ) ).list();
    assertNotNull( result );
    assertEquals( "Query with explicit criteria", 1, result.size() );
    book = (Book) result.get( 0 );
    assertTrue( "Association should be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
    assertEquals( 1, book.getAuthors().size() );
View Full Code Here

    s.close();

    //check non created object does get found!!1
    s = new FullTextSessionImpl( 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 ) s.clear();
View Full Code Here

    s = new FullTextSessionImpl( openSession() );
    tx = s.beginTransaction();
    parser = new QueryParser( "id", new 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
    tx = s.beginTransaction();
View Full Code Here

    s.close();

    //check non created object does get found!!1
    s = new FullTextSessionImpl( 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

    Query query = parser.parse( "name:moo" );
    FullTextQuery hibQuery = s.createFullTextQuery( query, Author.class, Music.class );
    List result = hibQuery.list();
    assertEquals( "Should have returned no author", 0, result.size() );

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

    tx.commit();
    s.close();
View Full Code Here

    }

    private void index() {
      em.getTransaction().begin();
        FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
        List<Book> results = ftSession.createCriteria(Book.class).list();
        for (Object obj : results) {
            ftSession.index(obj);
        }
        em.getTransaction().commit();
    }
View Full Code Here

    assertEquals( "Query with no explicit criteria", 1, result.size() );
    book = (Book) result.get( 0 );
    assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );

    result = s.createFullTextQuery( query ).setCriteriaQuery(
        s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN ) ).list();
    assertNotNull( result );
    assertEquals( "Query with explicit criteria", 1, result.size() );
    book = (Book) result.get( 0 );
    assertTrue( "Association should be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
    assertEquals( 1, book.getAuthors().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.