Examples of FullTextSession


Examples of org.hibernate.search.FullTextSession

   *
   * @throws Exception in case the test fails.
   */
  @SuppressWarnings( "unchecked" )
  public void testAddWorkGetReplacedByDeleteWork() throws Exception {
    FullTextSession fullTextSession = org.hibernate.search.Search.getFullTextSession( openSession() );
    SearchFactoryImpl searchFactory = ( SearchFactoryImpl ) fullTextSession.getSearchFactory();
    DocumentBuilderIndexedEntity builder = searchFactory.getDocumentBuilderIndexedEntity( SpecialPerson.class );

    // create test entity
    SpecialPerson person = new SpecialPerson();
    person.setName( "Joe Smith" );

    EmailAddress emailAddress = new EmailAddress();
    emailAddress.setAddress( "foo@foobar.com" );
    emailAddress.setDefaultAddress(true);

    person.addEmailAddress( emailAddress );

    List<LuceneWork> queue = new ArrayList<LuceneWork>();

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.ADD, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type", queue.get(0) instanceof AddLuceneWork );

    builder.addWorkToQueue( SpecialPerson.class, person, 1, WorkType.DELETE, queue, searchFactory );

    assertEquals("There should only be one job in the queue", 1, queue.size());
    assertTrue("Wrong job type. Add job should have been replaced by delete.", queue.get(0) instanceof DeleteLuceneWork );

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