src/main/java/cn/felord/mybatis/CrudMapperProvider.java
private void insert(Configuration configuration) {
        String insertId = mapperInterface.getName().concat(".").concat("insert");
         // xml配置中已经注册就跳过  xml中的优先级最高
        if (existStatement(configuration,insertId)){
            return;
        }
        // 生成数据库的字段列表
        String[] COLUMNS = columnFields.stream()
                .map(Field::getName)
                .map(CrudMapperProvider::camelCaseToMapUnderscore)
                .toArray(String[]::new);
        // 对应的值 用 #{} 包裹
        String[] VALUES = columnFields.stream()
                .map(Field::getName)
                .map(name -> String.format("#{%s}", name))
                .toArray(String[]::new);

        String insertSQL = new SQL()
                .INSERT_INTO(table)
                .INTO_COLUMNS(COLUMNS)
                .INTO_VALUES(VALUES)
                .toString();

        Map<String, Object> additionalParameters = new HashMap<>();
        // 注册
        doAddMappedStatement(configuration, insertId, insertSQL, SqlCommandType.INSERT, entityType, additionalParameters);
    }
/**
     * Insert.
     *
     * @param configuration the configuration
     */
Insert.
@param configuration the configuration
Insert . @param configuration the configuration
private void insert(Configuration configuration) {
        String insertId = mapperInterface.getName().concat(".").concat("insert");
        if (existStatement(configuration,insertId)){
            return;
        }
        String[] COLUMNS = columnFields.stream()
                .map(Field::getName)
                .map(CrudMapperProvider::camelCaseToMapUnderscore)
                .toArray(String[]::new);
        String[] VALUES = columnFields.stream()
                .map(Field::getName)
                .map(name -> String.format("#{%s}", name))
                .toArray(String[]::new);
        String insertSQL = new SQL()
                .INSERT_INTO(table)
                .INTO_COLUMNS(COLUMNS)
                .INTO_VALUES(VALUES)
                .toString();
        Map<String, Object> additionalParameters = new HashMap<>();
        doAddMappedStatement(configuration, insertId, insertSQL, SqlCommandType.INSERT, entityType, additionalParameters);
    }
private void insert ( Configuration configuration ) { String insertId = mapperInterface . getName ( ) . concat ( "." ) . concat ( "insert" ) ; if ( existStatement ( configuration , insertId ) ) { return ; } String [ ] COLUMNS = columnFields . stream ( ) . map ( Field :: getName ) . map ( CrudMapperProvider :: camelCaseToMapUnderscore ) . toArray ( String [ ] :: new ) ; String [ ] VALUES = columnFields . stream ( ) . map ( Field :: getName ) . map ( name -> String . format ( "#{%s}" , name ) ) . toArray ( String [ ] :: new ) ; String insertSQL = new SQL ( ) . INSERT_INTO ( table ) . INTO_COLUMNS ( COLUMNS ) . INTO_VALUES ( VALUES ) . toString ( ) ; Map < String , Object > additionalParameters = new HashMap < > ( ) ; doAddMappedStatement ( configuration , insertId , insertSQL , SqlCommandType . INSERT , entityType , additionalParameters ) ; }
Insert.
Insert .
// xml配置中已经注册就跳过  xml中的优先级最高 // 生成数据库的字段列表 // 对应的值 用 #{} 包裹 // 注册