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

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


    StringBuilder sb = new StringBuilder();
    sb.append("select * from "); //$NON-NLS-1$
    sb.append(introspectedTable
        .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement whereElement = new XmlElement("where"); //$NON-NLS-1$
    for (IntrospectedColumn introspectedColumn : introspectedTable
        .getAllColumns())
    {
      XmlElement isNotNullElement = new XmlElement("if"); //$NON-NLS-1$
      sb.setLength(0);
      sb.append(introspectedColumn.getJavaProperty()); //$NON-NLS-1$
      sb.append(" != null"); //$NON-NLS-1$
      isNotNullElement.addAttribute(new Attribute("test", sb.toString())); //$NON-NLS-1$

      sb.setLength(0);
      sb.append("and ");
      sb.append(MyBatis3FormattingUtilities
          .getAliasedEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(
          introspectedColumn, "")); //$NON-NLS-1$

      isNotNullElement.addElement(new TextElement(sb.toString()));

      whereElement.addElement(isNotNullElement);
    }
    answer.addElement(whereElement);

    parentElement.addElement(answer);

    // 生成selectCountByCriteria的sql映射
    parentElement = document.getRootElement();

    String fqjt = introspectedTable.getExampleType();
    answer = new XmlElement("select"); //$NON-NLS-1$
    answer
        .addAttribute(new Attribute(
            "id", "selectCount" + introspectedTable.getSelectByExampleStatementId().substring(6))); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", "long")); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    answer.addElement(new TextElement("select count(1) ")); //$NON-NLS-1$
    sb = new StringBuilder();
    sb.setLength(0);
    sb.append("from "); //$NON-NLS-1$
    sb.append(introspectedTable
        .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getExampleIncludeElement(introspectedTable));
    parentElement.addElement(answer);
    return true;
  }
View Full Code Here


  public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    XmlElement ifElement = new XmlElement("if");
    ifElement.addAttribute(new Attribute("test", "pageSize > 0"));
    ifElement.addElement(new TextElement("limit ${startIndex},${pageSize}"));
    element.addElement(ifElement);
    return true;
  }
View Full Code Here

  public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    XmlElement ifElement = new XmlElement("if");
    ifElement.addAttribute(new Attribute("test", "pageSize > 0"));
    ifElement.addElement(new TextElement("limit ${startIndex},${pageSize}"));
    element.addElement(ifElement);
    return true;
  }
View Full Code Here

    action.addAttribute(new Attribute("method", "{1}")); //$NON-NLS-1$
    pkg.addElement(action);

    XmlElement result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showIndex")); //$NON-NLS-1$
    TextElement text = new TextElement("/WEB-INF/jsp/"
        + recordLowerFullType + "/" + recordLowerFullType + ".jsp");
    result.addElement(text);
    action.addElement(result);

    result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showAdd")); //$NON-NLS-1$
    text = new TextElement("/WEB-INF/jsp/" + recordLowerFullType + "/add.jsp");
    result.addElement(text);
    action.addElement(result);

    result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showUpdate")); //$NON-NLS-1$
    text = new TextElement("/WEB-INF/jsp/" + recordLowerFullType + "/update.jsp");
    result.addElement(text);
    action.addElement(result);

    parent.addElement(pkg);
  }
View Full Code Here

   */
  @Override
  public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    element.addElement(0, new TextElement(
        "select * from (select a.*, rownum rn from ("));
    element.addElement(new TextElement(") a"));

    XmlElement whereElement_1 = new XmlElement("where");
    XmlElement ifElement_1 = new XmlElement("if");
    ifElement_1.addAttribute(new Attribute("test",
        "startIndex != null and pageSize != null"));
    ifElement_1.addElement(new TextElement(
        "rownum <= (${startIndex} + ${pageSize})"));
    whereElement_1.addElement(ifElement_1);
    element.addElement(whereElement_1);

    element.addElement(new TextElement(")"));

    XmlElement whereElement_2 = new XmlElement("where");
    XmlElement ifElement_2 = new XmlElement("if");
    ifElement_2.addAttribute(new Attribute("test", "startIndex != null"));
    ifElement_2.addElement(new TextElement("rn >= ${startIndex}"));
    whereElement_2.addElement(ifElement_2);
    element.addElement(whereElement_2);

    return true;
  }
View Full Code Here

   */
  @Override
  public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    element.addElement(0, new TextElement(
        "select * from (select a.*, rownum rn from ("));
    element.addElement(new TextElement(") a"));

    XmlElement whereElement_1 = new XmlElement("where");
    XmlElement ifElement_1 = new XmlElement("if");
    ifElement_1.addAttribute(new Attribute("test",
        "startIndex != null and pageSize != null"));
    ifElement_1.addElement(new TextElement(
        "rownum <= (${startIndex} + ${pageSize})"));
    whereElement_1.addElement(ifElement_1);
    element.addElement(whereElement_1);

    element.addElement(new TextElement(")"));

    XmlElement whereElement_2 = new XmlElement("where");
    XmlElement ifElement_2 = new XmlElement("if");
    ifElement_2.addAttribute(new Attribute("test", "startIndex != null"));
    ifElement_2.addElement(new TextElement("rn >= ${startIndex}"));
    whereElement_2.addElement(ifElement_2);
    element.addElement(whereElement_2);

    return true;
  }
View Full Code Here

          .getResource("/com/eatle/persistent/generator/generatorConfig.properties").toURI())));
      XmlElement selectKeyElement = new XmlElement("selectKey");
      selectKeyElement.addAttribute(new Attribute("resultType", "long"));
      selectKeyElement.addAttribute(new Attribute("keyProperty", "id"));
      selectKeyElement.addAttribute(new Attribute("order", "BEFORE"));
      selectKeyElement.addElement(new TextElement("select "
          + props.getProperty("sequenceName")
          + ".NEXTVAL as ID from dual "));

      element.addElement(selectKeyElement);
    }
View Full Code Here

      sb.setLength(0);
      sb.append(" and "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, "condition."));
      isNotNullElement.addElement(new TextElement(sb.toString()));
    }
    document.getRootElement().getElements().remove(2);
    return true;
  }
View Full Code Here

    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

    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

TOP

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

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.