diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/ExpressionsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/ExpressionsTest.java index bb6643df62..08de33245a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/ExpressionsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/basic/ExpressionsTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import jakarta.persistence.TypedQuery; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; import jakarta.persistence.criteria.ParameterExpression; import jakarta.persistence.criteria.Predicate; import jakarta.persistence.criteria.Root; @@ -87,6 +88,27 @@ public class ExpressionsTest extends AbstractMetamodelSpecificTest { ); } + @Test + @TestForIssue( jiraKey = "HHH-15452") + public void testGetConjunctionExpressionsAndAddPredicate(){ + inTransaction( + entityManager -> { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery criteria = builder.createQuery(Product.class); + Root rootClaseGrid = criteria.from(Product.class); + + Predicate conjuncion = builder.conjunction(); + Predicate expr = builder.equal(rootClaseGrid.get("id"), "NON existing id"); + // Modifications to the list do not affect the query + List> expressions = conjuncion.getExpressions(); + expressions.add( expr); + + List result = entityManager.createQuery( criteria ).getResultList(); + assertEquals( 1, result.size() ); + } + ); + } + @Test @TestForIssue(jiraKey = "HHH-6876") public void testEmptyInList() {