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

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


    return answer;
  }

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


    return answer;
  }

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

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

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

    String returnType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
      returnType = introspectedTable.getRecordWithBLOBsType();
    } else {
      // table has BLOBs, but no BLOB class - BLOB fields must be
      // in the base class
      returnType = introspectedTable.getBaseRecordType();
    }

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

    if (!introspectedTable.isConstructorBased()) {
      answer.addAttribute(new Attribute("extends", //$NON-NLS-1$
          introspectedTable.getBaseResultMapId()));
    }

    context.getCommentGenerator().addComment(answer);
View Full Code Here

  private void addResultMapElements(XmlElement answer) {
    for (IntrospectedColumn introspectedColumn : introspectedTable.getBLOBColumns()) {
      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", introspectedColumn.getJdbcTypeName())); //$NON-NLS-1$

      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", introspectedColumn.getJdbcTypeName())); //$NON-NLS-1$
      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.getNonPrimaryKeyColumns()) {
      XmlElement resultElement = new XmlElement("arg"); //$NON-NLS-1$

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

      if (introspectedColumn.getFullyQualifiedJavaType().isPrimitive()) {
        // need to use the MyBatis type alias for a primitive byte
        StringBuilder sb = new StringBuilder();
        sb.append('_');
        sb.append(introspectedColumn.getFullyQualifiedJavaType().getShortName());
        resultElement.addAttribute(new Attribute("javaType", //$NON-NLS-1$
            sb.toString()));

      } else if ("byte[]".equals(introspectedColumn.getFullyQualifiedJavaType() //$NON-NLS-1$
          .getFullyQualifiedName())) {
        // need to use the MyBatis type alias for a primitive byte arry
        resultElement.addAttribute(new Attribute("javaType", //$NON-NLS-1$
            "_byte[]")); //$NON-NLS-1$
      } else {
        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("sql"); //$NON-NLS-1$

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
View Full Code Here

  public void addElements(XmlElement parentElement) {
    String fqjt = introspectedTable.getExampleType();

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

    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
        introspectedTable.getSelectByExampleStatementId()));
    answer.addAttribute(new Attribute("resultMap", introspectedTable.getBaseResultMapId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    answer.addElement(new TextElement("select")); //$NON-NLS-1$
    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
    ifElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
    answer.addElement(ifElement);

    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());

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

    ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "orderByClause != null")); //$NON-NLS-1$ //$NON-NLS-2$
    ifElement.addElement(new TextElement("order by ${orderByClause}")); //$NON-NLS-1$
    answer.addElement(ifElement);

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

    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.getResultMapWithBLOBsId()));

    String returnType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
      returnType = introspectedTable.getRecordWithBLOBsType();
    } else {
      // table has BLOBs, but no BLOB class - BLOB fields must be
      // in the base class
      returnType = introspectedTable.getBaseRecordType();
    }

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

    StringBuilder sb = new StringBuilder();
    sb.append(introspectedTable.getIbatis2SqlMapNamespace());
    sb.append('.');
    sb.append(introspectedTable.getBaseResultMapId());
    answer.addAttribute(new Attribute("extends", sb.toString())); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

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

    for (IntrospectedColumn introspectedColumn : introspectedTable.getBLOBColumns()) {
      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", introspectedColumn.getJdbcTypeName())); //$NON-NLS-1$

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

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

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

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

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
View Full Code Here

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

    answer.addAttribute(new Attribute("id", //$NON-NLS-1$
        introspectedTable.getSelectByExampleStatementId()));
    answer.addAttribute(new Attribute("resultMap", introspectedTable.getBaseResultMapId())); //$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());

    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().sqlMapSelectByExampleWithoutBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
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.