HHH-13932 add test showing issue fixed

This commit is contained in:
Gavin King 2024-11-29 06:51:03 +01:00
parent 78cd996037
commit e0c95b77d6
1 changed files with 16 additions and 0 deletions

View File

@ -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<Item> query = builder.createQuery( Item.class );
Root<Item> root = query.from( Item.class );
ParameterExpression<String> parameter = builder.parameter( String.class, "name" );
Predicate predicate = builder.equal( root.get( "name" ), parameter );
query.where( predicate );
TypedQuery<Item> criteriaQuery = entityManager.createQuery( query );
ParameterExpression<String> nonExistingParam = builder.parameter( String.class, "nonExistingParam" );
criteriaQuery.setParameter( nonExistingParam, "George" );
} );
}
@Test @Test
public void testSetParameterPassingTypeNotFails() { public void testSetParameterPassingTypeNotFails() {
doInJPA( this::entityManagerFactory, entityManager -> { doInJPA( this::entityManagerFactory, entityManager -> {