src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
@Override
    public boolean sqlMapUpsertSelectiveElementGenerated(XmlElement element, List<IntrospectedColumn> columns, XmlElement insertColumnsEle, XmlElement insertValuesEle, XmlElement setsEle, IntrospectedTable introspectedTable) {
        // parameterType
        XmlElementTools.replaceAttribute(element, new Attribute("parameterType", "map"));
        // mybatis 3.5.0 之后对keyProperty处理有变更
        element.getAttributes().removeIf(attribute -> {
            String name = attribute.getName();
            return name.equals("useGeneratedKeys") || name.equals("keyProperty") || name.equals("keyColumn");
        });
        XmlElementGeneratorTools.useGeneratedKeys(element, introspectedTable, "record.");


        // 替换insert column
        XmlElementTools.replaceXmlElement(insertColumnsEle, this.generateInsertColumnSelective(columns));

        // 替换insert values
        XmlElementTools.replaceXmlElement(insertValuesEle, this.generateInsertValuesSelective(columns));

        // 替换update set
        XmlElementTools.replaceXmlElement(setsEle, this.generateSetsSelective(columns));

        return true;
    }
@Override
    public boolean sqlMapUpsertSelectiveElementGenerated(XmlElement element, List<IntrospectedColumn> columns, XmlElement insertColumnsEle, XmlElement insertValuesEle, XmlElement setsEle, IntrospectedTable introspectedTable) {
        // parameterType
        XmlElementTools.replaceAttribute(element, new Attribute("parameterType", "map"));
        // mybatis 3.5.0 之后对keyProperty处理有变更
        element.getAttributes().removeIf(attribute -> {
            String name = attribute.getName();
            return name.equals("useGeneratedKeys") || name.equals("keyProperty") || name.equals("keyColumn");
        });
        XmlElementGeneratorTools.useGeneratedKeys(element, introspectedTable, "record.");


        // 替换insert column
        XmlElementTools.replaceXmlElement(insertColumnsEle, this.generateInsertColumnSelective(columns));

        // 替换insert values
        XmlElementTools.replaceXmlElement(insertValuesEle, this.generateInsertValuesSelective(columns));

        // 替换update set
        XmlElementTools.replaceXmlElement(setsEle, this.generateSetsSelective(columns));

        return true;
    }
@ Override public boolean sqlMapUpsertSelectiveElementGenerated ( XmlElement element , List < IntrospectedColumn > columns , XmlElement insertColumnsEle , XmlElement insertValuesEle , XmlElement setsEle , IntrospectedTable introspectedTable ) { // parameterType XmlElementTools . replaceAttribute ( element , new Attribute ( "parameterType" , "map" ) ) ; // mybatis 3.5.0 之后对keyProperty处理有变更 element . getAttributes ( ) . removeIf ( attribute -> { String name = attribute . getName ( ) ; return name . equals ( "useGeneratedKeys" ) || name . equals ( "keyProperty" ) || name . equals ( "keyColumn" ) ; } ) ; XmlElementGeneratorTools . useGeneratedKeys ( element , introspectedTable , "record." ) ; // 替换insert column XmlElementTools . replaceXmlElement ( insertColumnsEle , this . generateInsertColumnSelective ( columns ) ) ; // 替换insert values XmlElementTools . replaceXmlElement ( insertValuesEle , this . generateInsertValuesSelective ( columns ) ) ; // 替换update set XmlElementTools . replaceXmlElement ( setsEle , this . generateSetsSelective ( columns ) ) ; return true ; }
upsertSelective xml
@param element
@param columns
@param insertColumnsEle
@param insertValuesEle
@param setsEle
@param introspectedTable
@return
upsertSelective xml