| 
5 | 5 | package org.hibernate.orm.test.query.hql;  | 
6 | 6 | 
 
  | 
7 | 7 | import jakarta.persistence.Entity;  | 
8 |  | -import jakarta.persistence.GeneratedValue;  | 
9 |  | -import jakarta.persistence.GenerationType;  | 
10 | 8 | import jakarta.persistence.Id;  | 
11 | 9 | 
 
  | 
 | 10 | +import org.hibernate.testing.orm.domain.gambit.SimpleEntity;  | 
12 | 11 | import org.hibernate.testing.orm.junit.JiraKey;  | 
13 | 12 | import org.hibernate.testing.orm.junit.DomainModel;  | 
14 | 13 | import org.hibernate.testing.orm.junit.SessionFactory;  | 
 | 
18 | 17 | /**  | 
19 | 18 |  * @author Andrea Boriero  | 
20 | 19 |  */  | 
 | 20 | +@SuppressWarnings("JUnitMalformedDeclaration")  | 
21 | 21 | @JiraKey( value = "HHH-11397")  | 
22 |  | -@DomainModel( annotatedClasses = QueryParametersValidationTest.TestEntity.class )  | 
 | 22 | +@DomainModel( annotatedClasses = {SimpleEntity.class, QueryParametersValidationTest.EntityWithBasicArray.class} )  | 
23 | 23 | @SessionFactory( exportSchema = false )  | 
24 | 24 | public class QueryParametersValidationTest {  | 
25 | 25 | 	@Test  | 
26 |  | -	public void setParameterWithWrongTypeShouldNotThrowIllegalArgumentException(SessionFactoryScope scope) {  | 
27 |  | -		scope.inTransaction(  | 
28 |  | -				(session) -> session.createQuery( "select e from TestEntity e where e.id = :id" )  | 
29 |  | -						.setParameter( "id", 1 )  | 
 | 26 | +	public void testSetParameterWithWrongType(SessionFactoryScope scope) {  | 
 | 27 | +		// SimpleEntity#id is of type Integer  | 
 | 28 | +		scope.inTransaction( (session) ->  | 
 | 29 | +				session.createQuery( "from SimpleEntity e where e.id = :p" )  | 
 | 30 | +						.setParameter( "p", 1L )  | 
30 | 31 | 		);  | 
31 | 32 | 	}  | 
32 | 33 | 
 
  | 
33 |  | -	@Entity(name = "TestEntity")  | 
34 |  | -	public class TestEntity {  | 
 | 34 | +	@Test  | 
 | 35 | +	public void testSetParameterWithArrayWithNullElement(SessionFactoryScope scope) {  | 
 | 36 | +		// SimpleEntity#id is of type Integer  | 
 | 37 | +		scope.inTransaction( (session) ->  | 
 | 38 | +				session.createQuery( "from EntityWithBasicArray e where e.strings = :p" )  | 
 | 39 | +						.setParameter( "p", new String[]{null, "something"} )  | 
 | 40 | +		);  | 
 | 41 | +	}  | 
35 | 42 | 
 
  | 
 | 43 | +	@Entity(name = "EntityWithBasicArray")  | 
 | 44 | +	public static class EntityWithBasicArray {  | 
36 | 45 | 		@Id  | 
37 |  | -		@GeneratedValue(strategy = GenerationType.AUTO)  | 
38 | 46 | 		private Long id;  | 
39 | 47 | 		private String name;  | 
 | 48 | +		private String[] strings;  | 
40 | 49 | 	}  | 
41 | 50 | }  | 
0 commit comments