* @author Emmanuel Bernard
*/
public class EntityManagerTest extends JPATestCase {
public void testQuery() throws Exception {
FullTextEntityManager em = Search.getFullTextEntityManager( factory.createEntityManager() );
em.getTransaction().begin();
Bretzel bretzel = new Bretzel( 23, 34 );
em.persist( bretzel );
em.getTransaction().commit();
em.clear();
em.getTransaction().begin();
QueryParser parser = new QueryParser( "title", new StopAnalyzer() );
Query query = parser.parse( "saltQty:noword" );
assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
query = new TermQuery( new Term("saltQty", "23.0") );
assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
assertEquals( "getSingleResult and object retrieval", 23f,
( (Bretzel) em.createFullTextQuery( query ).getSingleResult() ).getSaltQty() );
assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
em.getTransaction().commit();
em.clear();
em.getTransaction().begin();
em.remove( em.find( Bretzel.class, bretzel.getId() ) );
em.getTransaction().commit();
em.close();
}