public static String pkConditionSql(ESMapping mapping, Map<String, Object> data) {
        Set<ColumnItem> idColumns = new LinkedHashSet<>();
        SchemaItem schemaItem = mapping.getSchemaItem();

        TableItem mainTable = schemaItem.getMainTable();

        for (ColumnItem idColumnItem : schemaItem.getIdFieldItem(mapping).getColumnItems()) {
            if ((mainTable.getAlias() == null && idColumnItem.getOwner() == null)
                || (mainTable.getAlias() != null && mainTable.getAlias().equals(idColumnItem.getOwner()))) {
                idColumns.add(idColumnItem);
            }
        }

        if (idColumns.isEmpty()) {
            throw new RuntimeException("Not found primary key field in main table");
        }

        // 拼接condition
        StringBuilder condition = new StringBuilder(" ");
        for (ColumnItem idColumn : idColumns) {
            Object idVal = data.get(idColumn.getColumnName());
            if (mainTable.getAlias() != null) condition.append(mainTable.getAlias()).append(".");
            condition.append(idColumn.getColumnName()).append("=");
            if (idVal instanceof String) {
                condition.append("'").append(idVal).append("' AND ");
            } else {
                condition.append(idVal).append(" AND ");
            }
        }

        if (condition.toString().endsWith("AND ")) {
            int len2 = condition.length();
            condition.delete(len2 - 4, len2);
        }
        return condition.toString();
    }
public static String pkConditionSql ( ESMapping mapping , Map < String , Object > data ) { Set < ColumnItem > idColumns = new LinkedHashSet < > ( ) ; SchemaItem schemaItem = mapping . getSchemaItem ( ) ; TableItem mainTable = schemaItem . getMainTable ( ) ; for ( ColumnItem idColumnItem : schemaItem . getIdFieldItem ( mapping ) . getColumnItems ( ) ) { if ( ( mainTable . getAlias ( ) == null && idColumnItem . getOwner ( ) == null ) || ( mainTable . getAlias ( ) != null && mainTable . getAlias ( ) . equals ( idColumnItem . getOwner ( ) ) ) ) { idColumns . add ( idColumnItem ) ; } } if ( idColumns . isEmpty ( ) ) { throw new RuntimeException ( "Not found primary key field in main table" ) ; } StringBuilder condition = new StringBuilder ( " " ) ; for ( ColumnItem idColumn : idColumns ) { Object idVal = data . get ( idColumn . getColumnName ( ) ) ; if ( mainTable . getAlias ( ) != null ) condition . append ( mainTable . getAlias ( ) ) . append ( "." ) ; condition . append ( idColumn . getColumnName ( ) ) . append ( "=" ) ; if ( idVal instanceof String ) { condition . append ( "'" ) . append ( idVal ) . append ( "' AND " ) ; } else { condition . append ( idVal ) . append ( " AND " ) ; } } if ( condition . toString ( ) . endsWith ( "AND " ) ) { int len2 = condition . length ( ) ; condition . delete ( len2 - 4 , len2 ) ; } return condition . toString ( ) ; }
拼接主键条件

@param mapping
@param data
@return