HHH-7407 - Second collection-valued IN expression throws QuerySyntaxExpression
(cherry picked from commit 2ecf840f0e
)
This commit is contained in:
parent
67b973dc52
commit
8c5c986d8d
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.ejb.test.query;
|
package org.hibernate.ejb.test.query;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
@ -122,6 +123,43 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
em.close();
|
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<String> 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<String> 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
|
@Test
|
||||||
public void testParameterList() throws Exception {
|
public void testParameterList() throws Exception {
|
||||||
final Item item = new Item( "Mouse", "Micro$oft mouse" );
|
final Item item = new Item( "Mouse", "Micro$oft mouse" );
|
||||||
|
|
Loading…
Reference in New Issue