HHH-12225 - Fix test failing on PostgreSql

This commit is contained in:
Andrea Boriero 2018-02-22 12:58:05 +00:00
parent 5a9a1c5a87
commit 619a3f8445
1 changed files with 12 additions and 5 deletions

View File

@ -40,7 +40,8 @@ public class HQLTypeTest extends BaseCoreFunctionalTestCase {
@Test
public void test() throws Exception {
doInHibernate( this::sessionFactory, session -> {
VehicleContract contract = doInHibernate( this::sessionFactory, session -> {
VehicleContract firstCotract = null;
for ( long i = 0; i < 10; i++ ) {
VehicleContract vehicleContract = new VehicleContract();
Vehicle vehicle1 = new Vehicle();
@ -53,25 +54,31 @@ public class HQLTypeTest extends BaseCoreFunctionalTestCase {
session.save( vehicle2 );
session.save( vehicleContract );
session.save( vehicleTrackContract );
if ( i == 0 ) {
firstCotract = vehicleContract;
}
}
return firstCotract;
} );
doInHibernate( this::sessionFactory, session -> {
List workingResults = session.createQuery(
"select rootAlias.id from Contract as rootAlias where rootAlias.id = :id" )
.setParameter( "id", 1L )
.setParameter( "id", contract.getId() )
.getResultList();
assertFalse( workingResults.isEmpty() );
Long workingId = (Long) workingResults.get( 0 );
assertEquals( Long.valueOf( 1 ), workingId );
assertEquals( Long.valueOf( contract.getId() ), workingId );
List failingResults = session.createQuery(
"select rootAlias.id, type(rootAlias) from Contract as rootAlias where rootAlias.id = :id" )
.setParameter( "id", 1L )
.setParameter( "id", contract.getId() )
.getResultList();
assertFalse( failingResults.isEmpty() );
Long failingId = (Long) ( (Object[]) failingResults.get( 0 ) )[0];
assertEquals( Long.valueOf( 1 ), failingId );
assertEquals( Long.valueOf( contract.getId() ), failingId );
} );
}
}