em.close();
}
public void testNativeQueryWithPositionalParameter() {
Item item = new Item( "Mouse", "Micro$oft mouse" );
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
em.persist( item );
assertTrue( em.contains( item ) );
em.getTransaction().commit();
em.getTransaction().begin();
Query query = em.createNativeQuery( "select * from Item where name = ?1", Item.class );
query.setParameter( 1, "Mouse" );
item = (Item) query.getSingleResult();
assertNotNull( item );
assertEquals( "Micro$oft mouse", item.getDescr() );
query = em.createNativeQuery( "select * from Item where name = ?", Item.class );
query.setParameter( 1, "Mouse" );
item = (Item) query.getSingleResult();
assertNotNull( item );
assertEquals( "Micro$oft mouse", item.getDescr() );
em.remove( item );
em.getTransaction().commit();
em.close();