em.close();
}
public void testParameterListInExistingParens() throws Exception {
final Item item = new Item( "Mouse", "Micro$oft mouse" );
final Item item2 = new Item( "Computer", "Dell computer" );
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
em.persist( item );
em.persist( item2 );
assertTrue( em.contains( item ) );
em.getTransaction().commit();
em.getTransaction().begin();
Query q = em.createQuery( "select item from Item item where item.name in (:names)" );
//test hint in value and string
q.setHint( "org.hibernate.fetchSize", 10 );
q.setHint( "org.hibernate.fetchSize", "10" );
List params = new ArrayList();
params.add( item.getName() );
params.add( item2.getName() );
q.setParameter( "names", params );
List result = q.getResultList();
assertNotNull( result );
assertEquals( 2, result.size() );
q = em.createQuery( "select item from Item item where item.name in ( \n :names \n)\n" );
//test hint in value and string
q.setHint( "org.hibernate.fetchSize", 10 );
q.setHint( "org.hibernate.fetchSize", "10" );
params = new ArrayList();
params.add( item.getName() );
params.add( item2.getName() );
q.setParameter( "names", params );
result = q.getResultList();
assertNotNull( result );
assertEquals( 2, result.size() );
q = em.createQuery( "select item from Item item where item.name in ( ?1 )" );
params = new ArrayList();
params.add( item.getName() );
params.add( item2.getName() );
q.setParameter( "1", params );
result = q.getResultList();
assertNotNull( result );
assertEquals( 2, result.size() );
em.remove( result.get( 0 ) );