77import  jakarta .persistence .Entity ;
88import  jakarta .persistence .GeneratedValue ;
99import  jakarta .persistence .Id ;
10- import  org .hibernate .dialect . PostgreSQLDialect ;
10+ import  org .hibernate .testing . orm . junit . DialectFeatureChecks ;
1111import  org .hibernate .testing .orm .junit .DomainModel ;
1212import  org .hibernate .testing .orm .junit .JiraKey ;
13- import  org .hibernate .testing .orm .junit .RequiresDialect ;
13+ import  org .hibernate .testing .orm .junit .RequiresDialectFeature ;
1414import  org .hibernate .testing .orm .junit .SessionFactory ;
1515import  org .hibernate .testing .orm .junit .SessionFactoryScope ;
16+ import  org .junit .jupiter .api .AfterAll ;
1617import  org .junit .jupiter .api .BeforeEach ;
1718import  org .junit .jupiter .api .Test ;
1819
2627		}
2728)
2829@ SessionFactory 
29- @ RequiresDialect ( PostgreSQLDialect .class  )
30+ @ RequiresDialectFeature ( feature  = DialectFeatureChecks .SupportsStructuralArrays .class )
31+ @ RequiresDialectFeature ( feature  = DialectFeatureChecks .SupportsArrayPositions .class )
3032@ JiraKey ("HHH-19490" )
3133public  class  QuerySelectWhereArrayPositionTest  {
3234	@ BeforeEach 
@@ -40,15 +42,20 @@ public void setUp(SessionFactoryScope scope) {
4042		);
4143	}
4244
45+ 	@ AfterAll 
46+ 	public  void  tearDown (SessionFactoryScope  scope ) {
47+ 		scope .getSessionFactory ().getSchemaManager ().truncateMappedObjects ();
48+ 	}
49+ 
4350	@ Test 
4451	public  void  testSelectWhereArrayPosition (SessionFactoryScope  scope ) {
4552		scope .inTransaction ( session  -> {
4653			List <TestEntity > result  = session .createQuery ( "select testEntity " 
4754														+ "from TestEntity testEntity " 
48- 														+ "where ARRAY_POSITION(testEntity.values , ?1) IS NOT NULL " , TestEntity .class  )
49- 					.setParameter ( 1 , 3 )
55+ 														+ "where ARRAY_POSITION(testEntity.numbers , ?1) > 0 " , TestEntity .class  )
56+ 					.setParameter ( 1 , 2   )
5057					.getResultList ();
51- 			assertThat ( result .size () ).isEqualTo ( 3  );
58+ 			assertThat ( result .size () ).isEqualTo ( 2  );
5259		} );
5360	}
5461
@@ -59,13 +66,13 @@ public static class TestEntity {
5966		@ GeneratedValue 
6067		private  Long  id ;
6168
62- 		private  List <Integer > values ;
69+ 		private  List <Integer > numbers ;
6370
6471		public  TestEntity () {
6572		}
6673
67- 		public  TestEntity (List <Integer > values ) {
68- 			this .values  = values ;
74+ 		public  TestEntity (List <Integer > numbers ) {
75+ 			this .numbers  = numbers ;
6976		}
7077	}
7178}
0 commit comments