Skip to content

Commit

Permalink
HHH-12225 - Fix test failing on PostgreSql
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Feb 22, 2018
1 parent 0c17ef4 commit 8f670c5
Showing 1 changed file with 12 additions and 5 deletions.
Expand Up @@ -40,7 +40,8 @@ protected String getBaseForMappings() {

@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();
Expand All @@ -53,25 +54,31 @@ public void test() throws Exception {
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 );
} );
}
}

0 comments on commit 8f670c5

Please sign in to comment.