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

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


  }

  @Override
  public void addElements(XmlElement parentElement) {
    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("type", //$NON-NLS-1$
        returnType));

    context.getCommentGenerator().addComment(answer);

    if (introspectedTable.isConstructorBased()) {
View Full Code Here


  private void addResultMapElements(XmlElement answer) {
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      XmlElement resultElement = new XmlElement("id"); //$NON-NLS-1$

      resultElement.addAttribute(new Attribute(
          "column", MyBatis3FormattingUtilities.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);
    }

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

      resultElement.addAttribute(new Attribute(
          "column", MyBatis3FormattingUtilities.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

    XmlElement constructor = new XmlElement("constructor"); //$NON-NLS-1$

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

      resultElement.addAttribute(new Attribute(
          "column", MyBatis3FormattingUtilities.getRenamedColumnNameForResultMap(introspectedColumn))); //$NON-NLS-1$
      resultElement.addAttribute(new Attribute("jdbcType", //$NON-NLS-1$
          introspectedColumn.getJdbcTypeName()));
      resultElement.addAttribute(new Attribute("javaType", //$NON-NLS-1$
          introspectedColumn.getFullyQualifiedJavaType().getFullyQualifiedName()));

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

      constructor.addElement(resultElement);
    }

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

      resultElement.addAttribute(new Attribute(
          "column", MyBatis3FormattingUtilities.getRenamedColumnNameForResultMap(introspectedColumn))); //$NON-NLS-1$
      resultElement.addAttribute(new Attribute("jdbcType", //$NON-NLS-1$
          introspectedColumn.getJdbcTypeName()));
      resultElement.addAttribute(new Attribute("javaType", //$NON-NLS-1$
          introspectedColumn.getFullyQualifiedJavaType().getFullyQualifiedName()));

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

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

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

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

    FullyQualifiedJavaType parameterType = introspectedTable.getRules().calculateAllFieldsClass();

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

    context.getCommentGenerator().addComment(answer);

    GeneratedKey gk = introspectedTable.getGeneratedKey();
View Full Code Here

  @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();
View Full Code Here

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

    answer.addAttribute(new Attribute("id", introspectedTable.getUpdateByExampleWithBLOBsStatementId())); //$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()));

    // set up for first column
    sb.setLength(0);
    sb.append("set "); //$NON-NLS-1$

    Iterator<IntrospectedColumn> iter = introspectedTable.getAllColumns().iterator();
    while (iter.hasNext()) {
      IntrospectedColumn introspectedColumn = iter.next();

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

      if (iter.hasNext()) {
        sb.append(',');
      }

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

      // set up for the next column
      if (iter.hasNext()) {
        sb.setLength(0);
        OutputUtilities.xmlIndent(sb, 1);
      }
    }

    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().sqlMapUpdateByExampleWithBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
View Full Code Here

  @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("parameterType", //$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("set"); //$NON-NLS-1$
    answer.addElement(dynamicElement);

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

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

  }

  @Override
  public void addElements(XmlElement parentElement) {
    XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("id", introspectedTable.getSelectByExampleWithBLOBsStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultMap", introspectedTable.getResultMapWithBLOBsId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    answer.addElement(new TextElement("select")); //$NON-NLS-1$
    XmlElement isParameterPresent = new XmlElement("isParameterPresent"); //$NON-NLS-1$
    XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
    isEqualElement.addAttribute(new Attribute("property", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
    isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    isEqualElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
    isParameterPresent.addElement(isEqualElement);
    answer.addElement(isParameterPresent);

    StringBuilder sb = new StringBuilder();
    if (stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
      sb.append('\'');
      sb.append(introspectedTable.getSelectByExampleQueryId());
      sb.append("' as QUERYID,"); //$NON-NLS-1$
      answer.addElement(new TextElement(sb.toString()));
    }

    answer.addElement(getBaseColumnListElement());
    answer.addElement(new TextElement(",")); //$NON-NLS-1$
    answer.addElement(getBlobColumnListElement());

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

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

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

    XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
    isNotNullElement.addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
    isNotNullElement.addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
    isParameterPresenteElement.addElement(isNotNullElement);

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

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

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

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

    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("set"); //$NON-NLS-1$
    answer.addElement(dynamicElement);

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

      sb.setLength(0);
      sb.append(MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
View Full Code Here

  @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

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.