diff --git a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java index 13c03a1ef..8a87089a2 100644 --- a/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java +++ b/fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java @@ -650,11 +650,15 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information final int columnPosition = resultSet.getInt( "KEY_SEQ" ); + 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( "COLUMN_NAME" ) ); - final ColumnInformation column = tableInformation.getColumn( columnIdentifier ); - pkColumns.add( columnPosition-1, column ); + pkColumns.set( index, tableInformation.getColumn( columnIdentifier ) ); } } finally {