src/main/java/com/itfsw/mybatis/generator/plugins/OptimisticLockerPlugin.java
private XmlElement replaceExampleXmlElement(IntrospectedTable introspectedTable, XmlElement element, String id) {
        XmlElement withVersionEle = XmlElementTools.clone(element);

        XmlElementTools.replaceAttribute(withVersionEle, new Attribute("id", id));
        XmlElementTools.replaceAttribute(withVersionEle, new Attribute("parameterType", "map"));

        FormatTools.replaceComment(commentGenerator, withVersionEle);

        // 替换查询语句
        List<XmlElement> ifEles = XmlElementTools.findXmlElements(withVersionEle, "if");
        for (XmlElement ifEle : ifEles) {
            List<XmlElement> includeEles = XmlElementTools.findXmlElements(ifEle, "include");
            for (XmlElement includeEle : includeEles) {
                if (XmlElementTools.getAttribute(includeEle, "refid") != null) {
                    XmlElementTools.replaceAttribute(includeEle, new Attribute("refid", SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE));
                }
            }
        }

        return withVersionEle;
    }
private XmlElement replaceExampleXmlElement(IntrospectedTable introspectedTable, XmlElement element, String id) {
        XmlElement withVersionEle = XmlElementTools.clone(element);

        XmlElementTools.replaceAttribute(withVersionEle, new Attribute("id", id));
        XmlElementTools.replaceAttribute(withVersionEle, new Attribute("parameterType", "map"));

        FormatTools.replaceComment(commentGenerator, withVersionEle);

        // 替换查询语句
        List<XmlElement> ifEles = XmlElementTools.findXmlElements(withVersionEle, "if");
        for (XmlElement ifEle : ifEles) {
            List<XmlElement> includeEles = XmlElementTools.findXmlElements(ifEle, "include");
            for (XmlElement includeEle : includeEles) {
                if (XmlElementTools.getAttribute(includeEle, "refid") != null) {
                    XmlElementTools.replaceAttribute(includeEle, new Attribute("refid", SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE));
                }
            }
        }

        return withVersionEle;
    }
private XmlElement replaceExampleXmlElement ( IntrospectedTable introspectedTable , XmlElement element , String id ) { XmlElement withVersionEle = XmlElementTools . clone ( element ) ; XmlElementTools . replaceAttribute ( withVersionEle , new Attribute ( "id" , id ) ) ; XmlElementTools . replaceAttribute ( withVersionEle , new Attribute ( "parameterType" , "map" ) ) ; FormatTools . replaceComment ( commentGenerator , withVersionEle ) ; // 替换查询语句 List < XmlElement > ifEles = XmlElementTools . findXmlElements ( withVersionEle , "if" ) ; for ( XmlElement ifEle : ifEles ) { List < XmlElement > includeEles = XmlElementTools . findXmlElements ( ifEle , "include" ) ; for ( XmlElement includeEle : includeEles ) { if ( XmlElementTools . getAttribute ( includeEle , "refid" ) != null ) { XmlElementTools . replaceAttribute ( includeEle , new Attribute ( "refid" , SQL_UPDATE_BY_EXAMPLE_WITH_VERSION_WHERE_CLAUSE ) ) ; } } } return withVersionEle ; }
替换Example
@param introspectedTable
@param element
@param id
@return
替换Example