src/main/java/cn/felord/mybatis/CrudMapperProvider.java
private void updateById(Configuration configuration) {


        String updateId = mapperInterface.getName().concat(".").concat("updateById");

        if (existStatement(configuration,updateId)){
            return;
        }

        String[] SETS = columnFields.stream()
                .map(Field::getName)
                // 更新忽略主键
                .filter(name -> !identifer.equals(name))
                .map(name -> String.format("%s = #{%s}", camelCaseToMapUnderscore(name), name))
                .toArray(String[]::new);

        String CONDITION = primaryColumn().concat(" = #{" + identifer + "}");

        String updateSQL = new SQL().UPDATE(table)
                .SET(SETS)
                .WHERE(CONDITION).toString();

        Map<String, Object> additionalParameters = new HashMap<>();
        doAddMappedStatement(configuration, updateId, updateSQL, SqlCommandType.UPDATE, entityType, additionalParameters);

    }
/**
     * Update by id.
     *
     * @param configuration the configuration
     */
Update by id.
@param configuration the configuration
Update by id . @param configuration the configuration
private void updateById(Configuration configuration) {
        String updateId = mapperInterface.getName().concat(".").concat("updateById");
        if (existStatement(configuration,updateId)){
            return;
        }
        String[] SETS = columnFields.stream()
                .map(Field::getName)
                .filter(name -> !identifer.equals(name))
                .map(name -> String.format("%s = #{%s}", camelCaseToMapUnderscore(name), name))
                .toArray(String[]::new);
        String CONDITION = primaryColumn().concat(" = #{" + identifer + "}");
        String updateSQL = new SQL().UPDATE(table)
                .SET(SETS)
                .WHERE(CONDITION).toString();
        Map<String, Object> additionalParameters = new HashMap<>();
        doAddMappedStatement(configuration, updateId, updateSQL, SqlCommandType.UPDATE, entityType, additionalParameters);
    }
private void updateById ( Configuration configuration ) { String updateId = mapperInterface . getName ( ) . concat ( "." ) . concat ( "updateById" ) ; if ( existStatement ( configuration , updateId ) ) { return ; } String [ ] SETS = columnFields . stream ( ) . map ( Field :: getName ) . filter ( name -> ! identifer . equals ( name ) ) . map ( name -> String . format ( "%s = #{%s}" , camelCaseToMapUnderscore ( name ) , name ) ) . toArray ( String [ ] :: new ) ; String CONDITION = primaryColumn ( ) . concat ( " = #{" + identifer + "}" ) ; String updateSQL = new SQL ( ) . UPDATE ( table ) . SET ( SETS ) . WHERE ( CONDITION ) . toString ( ) ; Map < String , Object > additionalParameters = new HashMap < > ( ) ; doAddMappedStatement ( configuration , updateId , updateSQL , SqlCommandType . UPDATE , entityType , additionalParameters ) ; }
Update by id.
Update by id .
// 更新忽略主键