public Map<String, PrimaryKeyData> getPrimaryKeys(DatabaseMetaData md,
            String catalog, String schema, String tableName) throws SQLException {
        try (ResultSet primaryKeys = md.getPrimaryKeys(catalog, schema, tableName)) {
            Map<String, PrimaryKeyData> primaryKeyData = new TreeMap<String, PrimaryKeyData>();
            while (primaryKeys.next()) {
                String name = primaryKeys.getString(PK_NAME);
                String columnName = primaryKeys.getString(PK_COLUMN_NAME);
                if (name == null || name.isEmpty()) {
                    name = tableName + "_PK";
                }

                PrimaryKeyData data = primaryKeyData.get(name);
                if (data == null) {
                    data = new PrimaryKeyData(name);
                    primaryKeyData.put(name, data);
                }
                data.add(columnName);
            }
            return primaryKeyData;
        }
    }
{@code KeyDataFactory} is a factory for table key data

@author tiwe
querydsl-sql-codegen/src/main/java/com/querydsl/sql/codegen/KeyDataFactory.java