diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/CriteriaQueryTypeQueryAdapterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/CriteriaQueryTypeQueryAdapterTest.java index 050433e94f..5ee6e62de2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/CriteriaQueryTypeQueryAdapterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/criteria/CriteriaQueryTypeQueryAdapterTest.java @@ -111,6 +111,22 @@ public class CriteriaQueryTypeQueryAdapterTest extends BaseEntityManagerFunction } ); } + @Test(expected = IllegalArgumentException.class) + @JiraKey("HHH-13932") + public void testCriteriaQuerySetNonExistingParameter() { + doInJPA( this::entityManagerFactory, entityManager -> { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery( Item.class ); + Root root = query.from( Item.class ); + ParameterExpression parameter = builder.parameter( String.class, "name" ); + Predicate predicate = builder.equal( root.get( "name" ), parameter ); + query.where( predicate ); + TypedQuery criteriaQuery = entityManager.createQuery( query ); + ParameterExpression nonExistingParam = builder.parameter( String.class, "nonExistingParam" ); + criteriaQuery.setParameter( nonExistingParam, "George" ); + } ); + } + @Test public void testSetParameterPassingTypeNotFails() { doInJPA( this::entityManagerFactory, entityManager -> {