public void testEntityResurrection() {
final Long id = 5l;
Session session = getSessionFactory().openSession();
session.getTransaction().begin();
AlternateDocument docOnInfinispan = new AlternateDocument( id, "On Infinispan", "a book about Infinispan", "content" );
session.persist( docOnInfinispan );
session.getTransaction().commit();
session.clear();
session.getTransaction().begin();
FullTextSession fullTextSession = Search.getFullTextSession( session );
QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity( AlternateDocument.class ).get();
Query luceneQuery = queryBuilder.keyword().onField( "Abstract" ).matching( "Infinispan" ).createQuery();
List list = fullTextSession.createFullTextQuery( luceneQuery ).list();
Assert.assertEquals( 1, list.size() );
session.getTransaction().commit();
session.clear();
session.getTransaction().begin();
Object loadedDocument = session.load( AlternateDocument.class, id );
session.delete( loadedDocument );
session.getTransaction().commit();
session.clear();
session.getTransaction().begin();
list = fullTextSession.createFullTextQuery( luceneQuery ).list();
Assert.assertEquals( 0, list.size() );
AlternateDocument docOnHibernate = new AlternateDocument( id, "On Hibernate", "a book about Hibernate", "content" );
session.persist( docOnHibernate );
session.getTransaction().commit();
session.getTransaction().begin();
list = fullTextSession.createFullTextQuery( luceneQuery ).list();