HHH-4583 - Incorrect handling of empty conjunction and disjunction
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18823 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
d7de0dad4e
commit
5a4e37495e
|
@ -116,9 +116,9 @@ public class CompoundPredicate
|
|||
|
||||
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
|
||||
if ( getExpressions().size() == 0 ) {
|
||||
return getOperator() == Predicate.BooleanOperator.AND
|
||||
? "true"
|
||||
: "false";
|
||||
return getOperator() == BooleanOperator.AND
|
||||
? "1=1" // true
|
||||
: "0=1"; // false
|
||||
}
|
||||
if ( getExpressions().size() == 1 ) {
|
||||
return ( (Renderable) getExpressions().get(0) ).render( renderingContext );
|
||||
|
|
|
@ -25,6 +25,7 @@ package org.hibernate.ejb.criteria.basic;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
|
@ -69,6 +70,18 @@ public class ExpressionsTest extends AbstractMetamodelSpecificTest {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testEmptyConjunction() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
CriteriaQuery<Product> criteria = builder.createQuery( Product.class );
|
||||
criteria.from( Product.class );
|
||||
criteria.where( builder.and() );
|
||||
List<Product> result = em.createQuery( criteria ).getResultList();
|
||||
assertEquals( 1, result.size() );
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
public void testDiff() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
|
|
Loading…
Reference in New Issue