Transaction tx = s.beginTransaction();
QueryParser parser = new MultiFieldQueryParser(
new String[] { "name", "physicalDescription", "suspectCharge" },
new StandardAnalyzer()
);
FullTextQuery query = getQuery( "John Doe", parser, s );
assertTrue( query.getResultSize() != 0 );
query = getQuery( "green", parser, s );
random.nextInt( query.getResultSize() - 15 );
query.setFirstResult( random.nextInt( query.getResultSize() - 15 ) );
query.setMaxResults( 10 );
query.list();
tx.commit();
s.close();
s = sf.openSession();
tx = s.beginTransaction();
query = getQuery( "John Doe", parser, s );
assertTrue( query.getResultSize() != 0 );
query = getQuery( "thief", parser, s );
int firstResult = random.nextInt( query.getResultSize() - 15 );
query.setFirstResult( firstResult );
query.setMaxResults( 10 );
List result = query.list();
Object object = result.get( 0 );
if ( insert && object instanceof Detective ) {
Detective detective = ( Detective ) object;
detective.setPhysicalDescription( detective.getPhysicalDescription() + " Eye" + firstResult );
}