Package org.mybatis.generator.api.dom.xml

Examples of org.mybatis.generator.api.dom.xml.Attribute


    }
  }

  public XmlElement toXmlElement() {
    XmlElement xmlElement = new XmlElement("columnRenamingRule"); //$NON-NLS-1$
    xmlElement.addAttribute(new Attribute("searchString", searchString)); //$NON-NLS-1$

    if (replaceString != null) {
      xmlElement.addAttribute(new Attribute("replaceString", replaceString)); //$NON-NLS-1$
    }

    return xmlElement;
  }
View Full Code Here


    // 移除第一个
    Where_Clause.removeElement(0);

    StringBuilder sb = new StringBuilder();
    XmlElement dynamicElement = new XmlElement("trim"); //$NON-NLS-1$
    dynamicElement.addAttribute(new Attribute("prefix", "where")); //$NON-NLS-1$ //$NON-NLS-2$
    dynamicElement.addAttribute(new Attribute("prefixOverrides", "and|or")); //$NON-NLS-1$ //$NON-NLS-2$
    Where_Clause.addElement(dynamicElement);

    for (IntrospectedColumn introspectedColumn : introspectedTable.getNonPrimaryKeyColumns()) {
      XmlElement isNotNullElement = new XmlElement("if"); //$NON-NLS-1$
      if (isAllInOne) {
        String va = introspectedColumn.getJavaProperty("example.condition.") + " != null";
        isNotNullElement.addAttribute(new Attribute("test", va)); //$NON-NLS-1$ //$NON-NLS-2$
      } else {
        String va = introspectedColumn.getJavaProperty("condition.") + " != null";
        isNotNullElement.addAttribute(new Attribute("test", va)); //$NON-NLS-1$ //$NON-NLS-2$
      }
      dynamicElement.addElement(isNotNullElement);

      sb.setLength(0);
      sb.append(" and "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      if (isAllInOne) {
        sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, "example.condition."));

      } else {

        sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, "condition."));
      }
      isNotNullElement.addElement(new TextElement(sb.toString()));
    }
    if (!isAllInOne) {

      // Example_Where_Clause
      Where_Clause = (XmlElement) document.getRootElement().getElements().get(2);
      // 移除第一个
      Where_Clause.removeElement(0);

      sb = new StringBuilder();
      dynamicElement = new XmlElement("trim"); //$NON-NLS-1$
      dynamicElement.addAttribute(new Attribute("prefix", "where")); //$NON-NLS-1$ //$NON-NLS-2$
      dynamicElement.addAttribute(new Attribute("prefixOverrides", "and|or")); //$NON-NLS-1$ //$NON-NLS-2$
      Where_Clause.addElement(dynamicElement);

      for (IntrospectedColumn introspectedColumn : introspectedTable.getNonPrimaryKeyColumns()) {
        XmlElement isNotNullElement = new XmlElement("if"); //$NON-NLS-1$
        String va = introspectedColumn.getJavaProperty("example.condition.") + " != null";
        isNotNullElement.addAttribute(new Attribute("test", va)); //$NON-NLS-1$ //$NON-NLS-2$
        dynamicElement.addElement(isNotNullElement);

        sb.setLength(0);
        sb.append(" and "); //$NON-NLS-1$
        sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
View Full Code Here

  @Override
  public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(XmlElement element,
      IntrospectedTable introspectedTable) {
    if (databaseType.contains("oracle")) {
      XmlElement oracleHeadIncludeElement = new XmlElement("include");
      oracleHeadIncludeElement.addAttribute(new Attribute("refid", "common.Oracle_Pagination_Head"));
      // 在第一个地方增加
      element.addElement(0, oracleHeadIncludeElement);

      XmlElement oracleTailIncludeElement = new XmlElement("include");
      oracleTailIncludeElement.addAttribute(new Attribute("refid", "common.Oracle_Pagination_Tail"));
      // 在最后增加
      element.addElement(element.getElements().size(), oracleTailIncludeElement);
    } else if (databaseType.contains("mysql")) {
      XmlElement mysqlLimitIncludeElement = new XmlElement("include");
      mysqlLimitIncludeElement.addAttribute(new Attribute("refid", "common.Mysql_Pagination_Limit"));
      // 在最后增加
      element.addElement(element.getElements().size(), mysqlLimitIncludeElement);
    }
    return true;
  }
View Full Code Here

  @Override
  public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(XmlElement element,
      IntrospectedTable introspectedTable) {
    if (databaseType.contains("oracle")) {
      XmlElement oracleHeadIncludeElement = new XmlElement("include");
      oracleHeadIncludeElement.addAttribute(new Attribute("refid", "common.Oracle_Pagination_Head"));
      // 在第一个地方增加
      element.addElement(0, oracleHeadIncludeElement);

      XmlElement oracleTailIncludeElement = new XmlElement("include");
      oracleTailIncludeElement.addAttribute(new Attribute("refid", "common.Oracle_Pagination_Tail"));
      // 在最后增加
      element.addElement(element.getElements().size(), oracleTailIncludeElement);
    } else if (databaseType.contains("mysql")) {
      XmlElement mysqlLimitIncludeElement = new XmlElement("include");
      mysqlLimitIncludeElement.addAttribute(new Attribute("refid", "common.Mysql_Pagination_Limit"));
      // 在最后增加
      element.addElement(element.getElements().size(), mysqlLimitIncludeElement);
    }
    return true;
  }
View Full Code Here

  @Override
  public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles(IntrospectedTable introspectedTable) {
    Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID);
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    document.setRootElement(answer);
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
        "common"));

    if (databaseType.contains("oracle")) {
      answer.addElement(getOracleHead());
      answer.addElement(getOracleTail());
View Full Code Here

  }

  private XmlElement getOracleHead() {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", "Oracle_Pagination_Head")); //$NON-NLS-1$

    XmlElement outerisNotEmptyElement = new XmlElement("if");
    outerisNotEmptyElement.addAttribute(new Attribute("test", "limit != null and start != null"));
    outerisNotEmptyElement.addElement(new TextElement("<![CDATA[ select * from ( select row_.*, rownum rownum_ from ( ]]>"));
    answer.addElement(outerisNotEmptyElement);
    return answer;
  }
View Full Code Here

  }

  private XmlElement getOracleTail() {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", "Oracle_Pagination_Tail")); //$NON-NLS-1$

    XmlElement outerisNotEmptyElement = new XmlElement("if");
    outerisNotEmptyElement.addAttribute(new Attribute("test", "limit != null and start != null"));
    outerisNotEmptyElement.addElement(new TextElement(
        "<![CDATA[ ) row_ where rownum <= (#{limit} + #{start}) ) where rownum_ > #{start} ]]>"));
    answer.addElement(outerisNotEmptyElement);
    return answer;
  }
View Full Code Here

  }

  private XmlElement getMysqlLimit() {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

    answer.addAttribute(new Attribute("id", "Mysql_Pagination_Limit")); //$NON-NLS-1$

    XmlElement outerisNotEmptyElement = new XmlElement("if");
    outerisNotEmptyElement.addAttribute(new Attribute("test", "limit != null and start != null"));
    outerisNotEmptyElement.addElement(new TextElement("<![CDATA[ limit #{start} , #{limit} ]]>"));
    answer.addElement(outerisNotEmptyElement);
    return answer;
  }
View Full Code Here

  }

  public XmlElement toXmlElement() {
    XmlElement answer = new XmlElement("javaTypeResolver"); //$NON-NLS-1$
    if (getConfigurationType() != null) {
      answer.addAttribute(new Attribute("type", getConfigurationType())); //$NON-NLS-1$
    }

    addPropertyXmlElements(answer);

    return answer;
View Full Code Here

    this.driverClass = driverClass;
  }

  public XmlElement toXmlElement() {
    XmlElement xmlElement = new XmlElement("jdbcConnection"); //$NON-NLS-1$
    xmlElement.addAttribute(new Attribute("driverClass", driverClass)); //$NON-NLS-1$
    xmlElement.addAttribute(new Attribute("connectionURL", connectionURL)); //$NON-NLS-1$

    if (stringHasValue(userId)) {
      xmlElement.addAttribute(new Attribute("userId", userId)); //$NON-NLS-1$
    }

    if (stringHasValue(password)) {
      xmlElement.addAttribute(new Attribute("password", password)); //$NON-NLS-1$
    }

    addPropertyXmlElements(xmlElement);

    return xmlElement;
View Full Code Here

TOP

Related Classes of org.mybatis.generator.api.dom.xml.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.