diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java index 2c0502fea8..fafd4557d8 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/query/QueryTest.java @@ -24,6 +24,7 @@ package org.hibernate.ejb.test.query; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; import javax.persistence.EntityManager; @@ -122,6 +123,43 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase { em.close(); } + @Test + @TestForIssue( jiraKey = "HHH_7407" ) + public void testMultipleParameterLists() 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(); + + List names = Arrays.asList( item.getName() ); + Query q = em.createQuery( "select item from Item item where item.name in :names or item.name in :names2" ); + q.setParameter( "names", names ); + q.setParameter( "names2", names ); + List result = q.getResultList(); + assertNotNull( result ); + assertEquals( 1, result.size() ); + + List descrs = Arrays.asList( item.getDescr() ); + q = em.createQuery( "select item from Item item where item.name in :names and ( item.descr is null or item.descr in :descrs )" ); + q.setParameter( "names", names ); + q.setParameter( "descrs", descrs ); + result = q.getResultList(); + assertNotNull( result ); + assertEquals( 1, result.size() ); + + em.getTransaction().begin(); + em.remove( em.getReference( Item.class, item.getName() ) ); + em.remove( em.getReference( Item.class, item2.getName() ) ); + em.getTransaction().commit(); + + em.close(); + } + @Test public void testParameterList() throws Exception { final Item item = new Item( "Mouse", "Micro$oft mouse" );