src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
@Override
    public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
        // 1. batchInsert
        FullyQualifiedJavaType listType = FullyQualifiedJavaType.getNewListInstance();
        listType.addTypeArgument(introspectedTable.getRules().calculateAllFieldsClass());
        Method mBatchInsert = JavaElementGeneratorTools.generateMethod(
                METHOD_BATCH_INSERT,
                JavaVisibility.DEFAULT,
                FullyQualifiedJavaType.getIntInstance(),
                new Parameter(listType, "list", "@Param(\"list\")")

        );
        commentGenerator.addGeneralMethodComment(mBatchInsert, introspectedTable);
        // interface 增加方法
        FormatTools.addMethodWithBestPosition(interfaze, mBatchInsert);
        logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsert方法。");

        // 2. batchInsertSelective
        FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(introspectedTable.getRules().calculateAllFieldsClass().getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
        Method mBatchInsertSelective = JavaElementGeneratorTools.generateMethod(
                METHOD_BATCH_INSERT_SELECTIVE,
                JavaVisibility.DEFAULT,
                FullyQualifiedJavaType.getIntInstance(),
                new Parameter(listType, "list", "@Param(\"list\")"),
                new Parameter(selectiveType, "selective", "@Param(\"selective\")", true)
        );
        commentGenerator.addGeneralMethodComment(mBatchInsertSelective, introspectedTable);
        // interface 增加方法
        FormatTools.addMethodWithBestPosition(interfaze, mBatchInsertSelective);
        logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsertSelective方法。");

        return true;
    }
@Override
    public boolean clientGenerated(Interface interfaze, TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
        // 1. batchInsert
        FullyQualifiedJavaType listType = FullyQualifiedJavaType.getNewListInstance();
        listType.addTypeArgument(introspectedTable.getRules().calculateAllFieldsClass());
        Method mBatchInsert = JavaElementGeneratorTools.generateMethod(
                METHOD_BATCH_INSERT,
                JavaVisibility.DEFAULT,
                FullyQualifiedJavaType.getIntInstance(),
                new Parameter(listType, "list", "@Param(\"list\")")

        );
        commentGenerator.addGeneralMethodComment(mBatchInsert, introspectedTable);
        // interface 增加方法
        FormatTools.addMethodWithBestPosition(interfaze, mBatchInsert);
        logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsert方法。");

        // 2. batchInsertSelective
        FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType(introspectedTable.getRules().calculateAllFieldsClass().getShortName() + "." + ModelColumnPlugin.ENUM_NAME);
        Method mBatchInsertSelective = JavaElementGeneratorTools.generateMethod(
                METHOD_BATCH_INSERT_SELECTIVE,
                JavaVisibility.DEFAULT,
                FullyQualifiedJavaType.getIntInstance(),
                new Parameter(listType, "list", "@Param(\"list\")"),
                new Parameter(selectiveType, "selective", "@Param(\"selective\")", true)
        );
        commentGenerator.addGeneralMethodComment(mBatchInsertSelective, introspectedTable);
        // interface 增加方法
        FormatTools.addMethodWithBestPosition(interfaze, mBatchInsertSelective);
        logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsertSelective方法。");

        return true;
    }
@ Override public boolean clientGenerated ( Interface interfaze , TopLevelClass topLevelClass , IntrospectedTable introspectedTable ) { // 1. batchInsert FullyQualifiedJavaType listType = FullyQualifiedJavaType . getNewListInstance ( ) ; listType . addTypeArgument ( introspectedTable . getRules ( ) . calculateAllFieldsClass ( ) ) ; Method mBatchInsert = JavaElementGeneratorTools . generateMethod ( METHOD_BATCH_INSERT , JavaVisibility . DEFAULT , FullyQualifiedJavaType . getIntInstance ( ) , new Parameter ( listType , "list" , "@Param(\"list\")" ) ) ; commentGenerator . addGeneralMethodComment ( mBatchInsert , introspectedTable ) ; // interface 增加方法 FormatTools . addMethodWithBestPosition ( interfaze , mBatchInsert ) ; logger . debug ( "itfsw(批量插入插件):" + interfaze g tType().g e tShortN a m e () + "增加batc h I s rt方法。"); // 2. batchInsertSelective FullyQualifiedJavaType selectiveType = new FullyQualifiedJavaType ( introspectedTable . getRules ( ) . calculateAllFieldsClass ( ) . getShortName ( ) + "." + ModelColumnPlugin . ENUM_NAME ) ; Method mBatchInsertSelective = JavaElementGeneratorTools . generateMethod ( METHOD_BATCH_INSERT_SELECTIVE , JavaVisibility . DEFAULT , FullyQualifiedJavaType . getIntInstance ( ) , new Parameter ( listType , "list" , "@Param(\"list\")" ) , new Parameter ( selectiveType , "selective" , "@Param(\"selective\")" , true ) ) ; commentGenerator . addGeneralMethodComment ( mBatchInsertSelective , introspectedTable ) ; // interface 增加方法 FormatTools . addMethodWithBestPosition ( interfaze , mBatchInsertSelective ) ; logger . debug ( "itfsw(批量插入插件):" + interfaze g tType().g e tShortN a m e () + "增加batc h I s rtSelective方法。"); return true ; }
Java Client Methods 生成
具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
@param interfaze
@param topLevelClass
@param introspectedTable
@return
Java Client Methods 生成 具体执行顺序 http : // www . mybatis . org / generator / reference / pluggingIn . html