Package org.hibernate.search

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


    assertItsTheElephant( hibQuery.list() );

    hibQuery = s.createFullTextQuery( query, Serializable.class );
    assertItsTheElephant( hibQuery.list() );

    hibQuery = s.createFullTextQuery(
        query, Mammal.class, Animal.class, Being.class, Object.class, Serializable.class
    );
    assertItsTheElephant( hibQuery.list() );

    tx.commit();
View Full Code Here


    FullTextSession s = Search.getFullTextSession( openSession() );
    Transaction tx = s.beginTransaction();

    Query query = new TermQuery( new Term( "numberOfEggs", "2" ) );
    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Eagle.class );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 1, result.size() );

    query = new TermQuery( new Term( "numberOfEggs", "2" ) );
View Full Code Here

    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 1, result.size() );

    query = new TermQuery( new Term( "numberOfEggs", "2" ) );
    hibQuery = s.createFullTextQuery( query, Bird.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 2, result.size() );

    query = new TermQuery( new Term( "numberOfEggs", "2" ) );
View Full Code Here

    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 2, result.size() );

    query = new TermQuery( new Term( "numberOfEggs", "2" ) );
    hibQuery = s.createFullTextQuery( query, Mammal.class );
    result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 0, result.size() );

    try {
View Full Code Here

    assertNotNull( result );
    assertEquals( "Wrong number of hits. There should be two birds.", 0, result.size() );

    try {
      query = new TermQuery( new Term( "numberOfEggs", "2" ) );
      hibQuery = s.createFullTextQuery( query, String.class );
      hibQuery.list();
      fail();
    }
    catch ( IllegalArgumentException iae ) {
      log.debug( "success" );
View Full Code Here

    s.clear();
    tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "title", new StopAnalyzer() );

    Query query = parser.parse( "summary:Festina" );
    org.hibernate.Query hibQuery = s.createFullTextQuery( query, Book.class );
    List result = hibQuery.list();
    assertNotNull( result );
    assertEquals( "Query with no explicit criteria", 1, result.size() );
    book = (Book) result.get( 0 );
    assertFalse( "Association should not be inintialized", Hibernate.isInitialized( book.getAuthors() ) );
View Full Code Here

    assertNotNull( result );
    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() ) );
View Full Code Here

    s.clear();
    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );

    Query query = parser.parse( "dept:XXX" );
    org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );

    ScrollableResults projections = hibQuery.scroll();
    projections.beforeFirst();
    projections.next();
    Object[] projection = projections.get();
View Full Code Here

    projections.beforeFirst();
    projections.next();
    Object[] projection = projections.get();
    assertNull( projection );

    hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );

    projections = hibQuery.scroll();
    projections.beforeFirst();
    projections.next();
    projection = projections.get();
View Full Code Here

    s.clear();
    Transaction tx = s.beginTransaction();
    QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );

    Query query = parser.parse( "dept:XXX" );
    org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
    List result = hibQuery.list();
    assertEquals( 0, result.size() );

    hibQuery = s.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
    result = 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.