private XmlElement generateSqlMapUpdate(IntrospectedTable introspectedTable, List<IntrospectedColumn> columns, String id, boolean selective, boolean byExample) {
        // 移除版本列
        Iterator<IntrospectedColumn> columnIterator = columns.iterator();
        while (columnIterator.hasNext()) {
            IntrospectedColumn introspectedColumn = columnIterator.next();
            if (introspectedColumn.getActualColumnName().equals(this.versionColumn.getActualColumnName())) {
                columnIterator.remove();
            }
        }

        XmlElement updateEle = new XmlElement("update");

        updateEle.addAttribute(new Attribute("id", id));
        updateEle.addAttribute(new Attribute("parameterType", "map"));
        commentGenerator.addComment(updateEle);

        updateEle.addElement(new TextElement("update " + introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime()));
        if (selective) {
            XmlElement setEle = new XmlElement("set");
            updateEle.addElement(setEle);

            // set 节点
            XmlElement setsEle = XmlElementGeneratorTools.generateSetsSelective(columns, "record.");
            setEle.addElement(setsEle);

            XmlElement needVersionEle;
            if (PluginTools.getHook(IOptimisticLockerPluginHook.class).generateSetsSelectiveElement(columns, this.versionColumn, setsEle)) {
                needVersionEle = setEle;
            } else {
                needVersionEle = setsEle;
            }

            // 版本自增
            needVersionEle.addElement(0, this.generateVersionSetEle(selective));
        } else {
            // 版本自增
            updateEle.addElement(this.generateVersionSetEle(selective));
            // set 节点
            List<Element> setsEles = XmlElementGeneratorTools.generateSets(columns, "record.");
            //  XmlElementGeneratorTools.generateSets, 因为传入参数不可能带IdentityAndGeneratedAlwaysColumn所以返回的是set列表而不可能是trim 元素
            for (Element ele : setsEles) {
                updateEle.addElement(ele);
            }
        }

        // 更新条件
        if (byExample) {
            XmlElement ifElement = new XmlElement("if");
            ifElement.addAttribute(new Attribute("test", "_parameter != null"));

            XmlElement includeElement = new XmlElement("include");
            includeElement.addAttribute(new Attribute("refid", SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE));
            ifElement.addElement(includeElement);

            updateEle.addElement(ifElement);
        } else {
            updateEle = this.replacePrimaryKeyXmlElement(introspectedTable, updateEle, id, true);
        }

        return updateEle;
    }
private XmlElement generateSqlMapUpdate(IntrospectedTable introspectedTable, List<IntrospectedColumn> columns, String id, boolean selective, boolean byExample) {
        
        Iterator<IntrospectedColumn> columnIterator = columns.iterator();
        while (columnIterator.hasNext()) {
            IntrospectedColumn introspectedColumn = columnIterator.next();
            if (introspectedColumn.getActualColumnName().equals(this.versionColumn.getActualColumnName())) {
                columnIterator.remove();
            }
        }

        XmlElement updateEle = new XmlElement("update");

        updateEle.addAttribute(new Attribute("id", id));
        updateEle.addAttribute(new Attribute("parameterType", "map"));
        commentGenerator.addComment(updateEle);

        updateEle.addElement(new TextElement("update " + introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime()));
        if (selective) {
            XmlElement setEle = new XmlElement("set");
            updateEle.addElement(setEle);

            
            XmlElement setsEle = XmlElementGeneratorTools.generateSetsSelective(columns, "record.");
            setEle.addElement(setsEle);

            XmlElement needVersionEle;
            if (PluginTools.getHook(IOptimisticLockerPluginHook.class).generateSetsSelectiveElement(columns, this.versionColumn, setsEle)) {
                needVersionEle = setEle;
            } else {
                needVersionEle = setsEle;
            }

            
            needVersionEle.addElement(0, this.generateVersionSetEle(selective));
        } else {
            
            updateEle.addElement(this.generateVersionSetEle(selective));
            
            List<Element> setsEles = XmlElementGeneratorTools.generateSets(columns, "record.");
            
            for (Element ele : setsEles) {
                updateEle.addElement(ele);
            }
        }

        
        if (byExample) {
            XmlElement ifElement = new XmlElement("if");
            ifElement.addAttribute(new Attribute("test", "_parameter != null"));

            XmlElement includeElement = new XmlElement("include");
            includeElement.addAttribute(new Attribute("refid", SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE));
            ifElement.addElement(includeElement);

            updateEle.addElement(ifElement);
        } else {
            updateEle = this.replacePrimaryKeyXmlElement(introspectedTable, updateEle, id, true);
        }

        return updateEle;
    }
private XmlElement generateSqlMapUpdate ( IntrospectedTable introspectedTable , List < IntrospectedColumn > columns , String id , boolean selective , boolean byExample ) { // 移除版本列 Iterator < IntrospectedColumn > columnIterator = columns . iterator ( ) ; while ( columnIterator . hasNext ( ) ) { IntrospectedColumn introspectedColumn = columnIterator . next ( ) ; if ( introspectedColumn . getActualColumnName ( ) . equals ( this . versionColumn . getActualColumnName ( ) ) ) { columnIterator . remove ( ) ; } } XmlElement updateEle = new XmlElement ( "update" ) ; updateEle . addAttribute ( new Attribute ( "id" , id ) ) ; updateEle . addAttribute ( new Attribute ( "parameterType" , "map" ) ) ; commentGenerator . addComment ( updateEle ) ; updateEle . addElement ( new TextElement ( "update " + introspectedTable . getAliasedFullyQualifiedTableNameAtRuntime ( ) ) ) ; if ( selective ) { XmlElement setEle = new XmlElement ( "set" ) ; updateEle . addElement ( setEle ) ; // set 节点 XmlElement setsEle = XmlElementGeneratorTools . generateSetsSelective ( columns , "record." ) ; setEle . addElement ( setsEle ) ; XmlElement needVersionEle ; if ( PluginTools . getHook ( IOptimisticLockerPluginHook . class ) . generateSetsSelectiveElement ( columns , this . versionColumn , setsEle ) ) { needVersionEle = setEle ; } else { needVersionEle = setsEle ; } // 版本自增 needVersionEle . addElement ( 0 , this . generateVersionSetEle ( selective ) ) ; } else { // 版本自增 updateEle . addElement ( this . generateVersionSetEle ( selective ) ) ; // set 节点 List < Element > setsEles = XmlElementGeneratorTools . generateSets ( columns , "record." ) ; //  XmlElementGeneratorTools.generateSets, 因为传入参数不可能带IdentityAndGeneratedAlwaysColumn所以返回的是set列表而不可能是trim 元素 for ( Element ele : setsEles ) { updateEle . addElement ( ele ) ; } } // 更新条件 if ( byExample ) { XmlElement ifElement = new XmlElement ( "if" ) ; ifElement . addAttribute ( new Attribute ( "test" , "_parameter != null" ) ) ; XmlElement includeElement = new XmlElement ( "include" ) ; includeElement . addAttribute ( new Attribute ( "refid" , SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE ) ) ; ifElement . addElement ( includeElement ) ; updateEle . addElement ( ifElement ) ; } else { updateEle = this . replacePrimaryKeyXmlElement ( introspectedTable , updateEle , id , true ) ; } return updateEle ; }
生成update sql map
@param introspectedTable
@param columns
@param id
@param selective
@param byExample
@return
生成update sql map