@Test(groups = "ch07") public void testPrefixQuery() throws Exception { FullTextSession session = Search.getFullTextSession(openSession()); Transaction tx = session.beginTransaction(); buildIndex(session, tx); String userInput = "sea"; tx = session.beginTransaction(); PrefixQuery query = new PrefixQuery(new Term("title", userInput)); System.out.println(query.toString()); org.hibernate.search.FullTextQuery hibQuery = session.createFullTextQuery(query, Dvd.class); List<Dvd> results = hibQuery.list(); assert results.size() == 4 : "incorrect hit count"; for (Dvd dvd : results) { assert dvd.getTitle().indexOf("Sea") >= 0; System.out.println(dvd.getTitle()); } for (Object element : session.createQuery("from " + Dvd.class.getName()).list()) session.delete(element); tx.commit(); session.close(); }
public Object getValueAt(int row, int col) { Dvd theDvd = data.get(row); Object theData = null; switch (col) { case 0: theData = theDvd.getTitle(); break; case 1: theData = theDvd.getCategory(); break; case 2: theData = theDvd.getRunningTime(); break; case 3: theData = theDvd.getYearReleased(); break; case 4: theData = theDvd.getPrice(); break; default: break; } return theData; }