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

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


  @Override
  public void addElements(XmlElement parentElement) {
    boolean useColumnIndex = isTrue(introspectedTable
        .getTableConfigurationProperty(PropertyRegistry.TABLE_USE_COLUMN_INDEXES));
    XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
        introspectedTable.getBaseResultMapId()));

    String returnType;
    if (introspectedTable.getRules().generateBaseRecordClass()) {
      returnType = introspectedTable.getBaseRecordType();
    } else {
      returnType = introspectedTable.getPrimaryKeyType();
    }

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

    context.getCommentGenerator().addComment(answer);

    int i = 1;
    if (stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())
        || stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
      i++;
    }

    for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
      XmlElement resultElement = new XmlElement("result"); //$NON-NLS-1$

      if (useColumnIndex) {
        resultElement.addAttribute(new Attribute("columnIndex", Integer.toString(i++))); //$NON-NLS-1$
      } else {
        resultElement.addAttribute(new Attribute(
            "column", Ibatis2FormattingUtilities.getRenamedColumnNameForResultMap(introspectedColumn))); //$NON-NLS-1$
      }

      resultElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
      resultElement.addAttribute(new Attribute("jdbcType", //$NON-NLS-1$
          introspectedColumn.getJdbcTypeName()));

      if (stringHasValue(introspectedColumn.getTypeHandler())) {
        resultElement.addAttribute(new Attribute("typeHandler", introspectedColumn.getTypeHandler())); //$NON-NLS-1$
      }

      answer.addElement(resultElement);
    }
View Full Code Here


    super();
  }

  @Override
  public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    Iterator<IntrospectedColumn> iter = introspectedTable.getNonBLOBColumns().iterator();
    while (iter.hasNext()) {
      sb.append(Ibatis2FormattingUtilities.getSelectListPhrase(iter.next()));

      if (iter.hasNext()) {
        sb.append(", "); //$NON-NLS-1$
      }

      if (sb.length() > 80) {
        answer.addElement(new TextElement(sb.toString()));
        sb.setLength(0);
      }
    }

    if (sb.length() > 0) {
      answer.addElement((new TextElement(sb.toString())));
    }

    if (context.getPlugins().sqlMapBaseColumnListElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

   * @return the selectKey element
   */
  protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn.getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", identityColumnType)); //$NON-NLS-1$
    answer.addAttribute(new Attribute("keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("order", //$NON-NLS-1$
        generatedKey.getMyBatis3Order()));

    answer.addElement(new TextElement(generatedKey.getRuntimeSqlStatement()));

    return answer;
  }
View Full Code Here

    return answer;
  }

  protected XmlElement getBaseColumnListElement() {
    XmlElement answer = new XmlElement("include"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getBaseColumnListId()));
    return answer;
  }
View Full Code Here

    super();
  }

  @Override
  public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("update"); //$NON-NLS-1$

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

    String parameterType;

    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
      parameterType = introspectedTable.getRecordWithBLOBsType();
    } else {
      parameterType = introspectedTable.getBaseRecordType();
    }

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();

    sb.append("update "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
    dynamicElement.addAttribute(new Attribute("prepend", "set")); //$NON-NLS-1$ //$NON-NLS-2$
    answer.addElement(dynamicElement);

    for (IntrospectedColumn introspectedColumn : introspectedTable.getNonPrimaryKeyColumns()) {
      XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
      isNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
      isNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
      dynamicElement.addElement(isNotNullElement);

      sb.setLength(0);
      sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn));

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

    boolean and = false;
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      sb.setLength(0);
View Full Code Here

        introspectedTable.getBaseColumnListId()));
    return answer;
  }

  protected XmlElement getBlobColumnListElement() {
    XmlElement answer = new XmlElement("include"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getBlobColumnListId()));
    return answer;
  }
View Full Code Here

        introspectedTable.getBlobColumnListId()));
    return answer;
  }

  protected XmlElement getExampleIncludeElement() {
    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "_parameter != null")); //$NON-NLS-1$ //$NON-NLS-2$

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getExampleWhereClauseId()));
    ifElement.addElement(includeElement);

    return ifElement;
  }
View Full Code Here

    return ifElement;
  }

  protected XmlElement getUpdateByExampleIncludeElement() {
    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "_parameter != null")); //$NON-NLS-1$ //$NON-NLS-2$

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getMyBatis3UpdateByExampleWhereClauseId()));
    ifElement.addElement(includeElement);

    return ifElement;
  }
View Full Code Here

    super();
  }

  @Override
  public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("update"); //$NON-NLS-1$

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();

    sb.append("update "); //$NON-NLS-1$
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
    dynamicElement.addAttribute(new Attribute("prepend", "set")); //$NON-NLS-1$ //$NON-NLS-2$
    answer.addElement(dynamicElement);

    for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
      XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
      isNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
      isNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty("record."))); //$NON-NLS-1$ //$NON-NLS-2$
      dynamicElement.addElement(isNotNullElement);

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

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

    XmlElement isParameterPresentElement = new XmlElement("isParameterPresent"); //$NON-NLS-1$
    answer.addElement(isParameterPresentElement);

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getIbatis2SqlMapNamespace() + "." + introspectedTable.getExampleWhereClauseId())); //$NON-NLS-1$
    isParameterPresentElement.addElement(includeElement);

    if (context.getPlugins().sqlMapUpdateByExampleSelectiveElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
View Full Code Here

    super();
  }

  @Override
  public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();

    Iterator<IntrospectedColumn> iter = introspectedTable.getBLOBColumns().iterator();
    while (iter.hasNext()) {
      sb.append(MyBatis3FormattingUtilities.getSelectListPhrase(iter.next()));

      if (iter.hasNext()) {
        sb.append(", "); //$NON-NLS-1$
      }

      if (sb.length() > 80) {
        answer.addElement(new TextElement(sb.toString()));
        sb.setLength(0);
      }
    }

    if (sb.length() > 0) {
      answer.addElement((new TextElement(sb.toString())));
    }

    if (context.getPlugins().sqlMapBlobColumnListElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

TOP

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

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.