HHH-15356 Unable to get primary information on some dialects (ex: Oracle) when the PK column's position doesn't match the alphabetical name's order

This commit is contained in:
Andrea Boriero 2022-09-01 16:06:34 +02:00 committed by Andrea Boriero
parent 4265cc0ff9
commit 38c8dc90c3
1 changed files with 6 additions and 2 deletions

View File

@ -996,11 +996,15 @@ public abstract class AbstractInformationExtractorImpl implements InformationExt
final int columnPosition = resultSet.getInt( getResultSetColumnPositionColumn() );
final int index = columnPosition - 1;
// Fill up the array list with nulls up to the desired index, because some JDBC drivers don't return results ordered by column position
while ( pkColumns.size() <= index ) {
pkColumns.add( null );
}
final Identifier columnIdentifier = DatabaseIdentifier.toIdentifier(
resultSet.getString( getResultSetColumnNameLabel() )
);
final ColumnInformation column = tableInformation.getColumn( columnIdentifier );
pkColumns.add( columnPosition-1, column );
pkColumns.set( index, tableInformation.getColumn( columnIdentifier ) );
}
if ( firstPass ) {
// we did not find any results (no pk)