Skip to content

Commit 8f670c5

Browse files
committed
HHH-12225 - Fix test failing on PostgreSql
1 parent 0c17ef4 commit 8f670c5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

hibernate-core/src/test/java/org/hibernate/query/hhh12225/HQLTypeTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ protected String getBaseForMappings() {
4040

4141
@Test
4242
public void test() throws Exception {
43-
doInHibernate( this::sessionFactory, session -> {
43+
VehicleContract contract = doInHibernate( this::sessionFactory, session -> {
44+
VehicleContract firstCotract = null;
4445
for ( long i = 0; i < 10; i++ ) {
4546
VehicleContract vehicleContract = new VehicleContract();
4647
Vehicle vehicle1 = new Vehicle();
@@ -53,25 +54,31 @@ public void test() throws Exception {
5354
session.save( vehicle2 );
5455
session.save( vehicleContract );
5556
session.save( vehicleTrackContract );
57+
if ( i == 0 ) {
58+
firstCotract = vehicleContract;
59+
}
5660
}
61+
return firstCotract;
62+
} );
5763

64+
doInHibernate( this::sessionFactory, session -> {
5865
List workingResults = session.createQuery(
5966
"select rootAlias.id from Contract as rootAlias where rootAlias.id = :id" )
60-
.setParameter( "id", 1L )
67+
.setParameter( "id", contract.getId() )
6168
.getResultList();
6269

6370
assertFalse( workingResults.isEmpty() );
6471
Long workingId = (Long) workingResults.get( 0 );
65-
assertEquals( Long.valueOf( 1 ), workingId );
72+
assertEquals( Long.valueOf( contract.getId() ), workingId );
6673

6774
List failingResults = session.createQuery(
6875
"select rootAlias.id, type(rootAlias) from Contract as rootAlias where rootAlias.id = :id" )
69-
.setParameter( "id", 1L )
76+
.setParameter( "id", contract.getId() )
7077
.getResultList();
7178

7279
assertFalse( failingResults.isEmpty() );
7380
Long failingId = (Long) ( (Object[]) failingResults.get( 0 ) )[0];
74-
assertEquals( Long.valueOf( 1 ), failingId );
81+
assertEquals( Long.valueOf( contract.getId() ), failingId );
7582
} );
7683
}
7784
}

0 commit comments

Comments
 (0)