src/main/java/com/itfsw/mybatis/generator/plugins/SelectSelectivePlugin.java
private XmlElement generateSelectiveElement(IntrospectedTable introspectedTable) {
        XmlElement chooseEle = new XmlElement("choose");

        XmlElement whenEle = new XmlElement("when");
        whenEle.addAttribute(new Attribute("test", "selective != null and selective.length > 0"));
        chooseEle.addElement(whenEle);

        // 生成返回字段节点
        XmlElement keysEle = new XmlElement("foreach");
        whenEle.addElement(keysEle);
        keysEle.addAttribute(new Attribute("collection", "selective"));
        keysEle.addAttribute(new Attribute("item", "column"));
        keysEle.addAttribute(new Attribute("separator", ","));
        keysEle.addElement(new TextElement("${column.aliasedEscapedColumnName}"));

        XmlElement otherwiseEle = new XmlElement("otherwise");
        chooseEle.addElement(otherwiseEle);
        // 存在关键词column或者table定义了alias属性,这里直接使用对应的ColumnListElement
        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
            otherwiseEle.addElement(XmlElementGeneratorTools.getBaseColumnListElement(introspectedTable));
            otherwiseEle.addElement(new TextElement(","));
            otherwiseEle.addElement(XmlElementGeneratorTools.getBlobColumnListElement(introspectedTable));
        } else {
            otherwiseEle.addElement(XmlElementGeneratorTools.getBaseColumnListElement(introspectedTable));
        }

        return chooseEle;
    }
private XmlElement generateSelectiveElement(IntrospectedTable introspectedTable) {
        XmlElement chooseEle = new XmlElement("choose");

        XmlElement whenEle = new XmlElement("when");
        whenEle.addAttribute(new Attribute("test", "selective != null and selective.length > 0"));
        chooseEle.addElement(whenEle);

        // 生成返回字段节点
        XmlElement keysEle = new XmlElement("foreach");
        whenEle.addElement(keysEle);
        keysEle.addAttribute(new Attribute("collection", "selective"));
        keysEle.addAttribute(new Attribute("item", "column"));
        keysEle.addAttribute(new Attribute("separator", ","));
        keysEle.addElement(new TextElement("${column.aliasedEscapedColumnName}"));

        XmlElement otherwiseEle = new XmlElement("otherwise");
        chooseEle.addElement(otherwiseEle);
        // 存在关键词column或者table定义了alias属性,这里直接使用对应的ColumnListElement
        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
            otherwiseEle.addElement(XmlElementGeneratorTools.getBaseColumnListElement(introspectedTable));
            otherwiseEle.addElement(new TextElement(","));
            otherwiseEle.addElement(XmlElementGeneratorTools.getBlobColumnListElement(introspectedTable));
        } else {
            otherwiseEle.addElement(XmlElementGeneratorTools.getBaseColumnListElement(introspectedTable));
        }

        return chooseEle;
    }
private XmlElement generateSelectiveElement ( IntrospectedTable introspectedTable ) { XmlElement chooseEle = new XmlElement ( "choose" ) ; XmlElement whenEle = new XmlElement ( "when" ) ; whenEle . addAttribute ( new Attribute ( "test" , "selective != null and selective.length > 0" ) ) ; chooseEle . addElement ( whenEle ) ; // 生成返回字段节点 XmlElement keysEle = new XmlElement ( "foreach" ) ; whenEle . addElement ( keysEle ) ; keysEle . addAttribute ( new Attribute ( "collection" , "selective" ) ) ; keysEle . addAttribute ( new Attribute ( "item" , "column" ) ) ; keysEle . addAttribute ( new Attribute ( "separator" , "," ) ) ; keysEle . addElement ( new TextElement ( "${column.aliasedEscapedColumnName}" ) ) ; XmlElement otherwiseEle = new XmlElement ( "otherwise" ) ; chooseEle . addElement ( otherwiseEle ) ; // 存在关键词column或者table定义了alias属性,这里直接使用对应的ColumnListElement if ( introspectedTable . getRules ( ) . generateSelectByExampleWithBLOBs ( ) ) { otherwiseEle . addElement ( XmlElementGeneratorTools . getBaseColumnListElement ( introspectedTable ) ) ; otherwiseEle . addElement ( new TextElement ( "," ) ) ; otherwiseEle . addElement ( XmlElementGeneratorTools . getBlobColumnListElement ( introspectedTable ) ) ; } else { otherwiseEle . addElement ( XmlElementGeneratorTools . getBaseColumnListElement ( introspectedTable ) ) ; } return chooseEle ; }
生成Selective xml节点
@param introspectedTable
@return
生成Selective xml节点