From 3a0c725cf3225f3f7ba17119659a1887b7e6c7ee Mon Sep 17 00:00:00 2001 From: Lukasz Antoniak Date: Tue, 19 Feb 2013 17:12:45 -0500 Subject: [PATCH] HHH-6876 - Test case --- .../ejb/criteria/basic/ExpressionsTest.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java index d082113757..ced48cab7f 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java @@ -23,10 +23,13 @@ */ package org.hibernate.ejb.criteria.basic; +import static org.junit.Assert.assertEquals; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Collections; import java.util.List; + import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; @@ -35,18 +38,18 @@ import javax.persistence.criteria.ParameterExpression; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - import org.hibernate.Query; +import org.hibernate.dialect.H2Dialect; import org.hibernate.ejb.metamodel.AbstractMetamodelSpecificTest; import org.hibernate.ejb.metamodel.Phone; import org.hibernate.ejb.metamodel.Product; import org.hibernate.ejb.metamodel.Product_; import org.hibernate.internal.AbstractQueryImpl; - -import static org.junit.Assert.assertEquals; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.TestForIssue; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; /** * Tests that various expressions operate as expected @@ -97,6 +100,21 @@ public class ExpressionsTest extends AbstractMetamodelSpecificTest { em.close(); } + @Test + @TestForIssue( jiraKey = "HHH-6876" ) + @RequiresDialect( H2Dialect.class ) + public void testEmptyInList() { + EntityManager em = getOrCreateEntityManager(); + em.getTransaction().begin(); + CriteriaQuery criteria = builder.createQuery( Product.class ); + Root from = criteria.from( Product.class ); + criteria.where( from.get( Product_.partNumber ).in() ); // empty IN list + List result = em.createQuery( criteria ).getResultList(); + assertEquals( 0, result.size() ); + em.getTransaction().commit(); + em.close(); + } + @Test public void testEmptyConjunctionIsTrue() { EntityManager em = getOrCreateEntityManager();