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("sql"); //$NON-NLS-1$

    if (isForUpdateByExample) {
      answer.addAttribute(new Attribute("id", introspectedTable.getMyBatis3UpdateByExampleWhereClauseId())); //$NON-NLS-1$
    } else {
      answer.addAttribute(new Attribute("id", introspectedTable.getExampleWhereClauseId())); //$NON-NLS-1$
    }

    context.getCommentGenerator().addComment(answer);

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

    XmlElement outerForEachElement = new XmlElement("foreach"); //$NON-NLS-1$
    if (isForUpdateByExample) {
      outerForEachElement.addAttribute(new Attribute("collection", "example.oredCriteria")); //$NON-NLS-1$ //$NON-NLS-2$
    } else {
      outerForEachElement.addAttribute(new Attribute("collection", "oredCriteria")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    outerForEachElement.addAttribute(new Attribute("item", "criteria")); //$NON-NLS-1$ //$NON-NLS-2$
    outerForEachElement.addAttribute(new Attribute("separator", "or")); //$NON-NLS-1$ //$NON-NLS-2$
    whereElement.addElement(outerForEachElement);

    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "criteria.valid")); //$NON-NLS-1$ //$NON-NLS-2$
    outerForEachElement.addElement(ifElement);

    XmlElement trimElement = new XmlElement("trim"); //$NON-NLS-1$
    trimElement.addAttribute(new Attribute("prefix", "(")); //$NON-NLS-1$ //$NON-NLS-2$
    trimElement.addAttribute(new Attribute("suffix", ")")); //$NON-NLS-1$ //$NON-NLS-2$
    trimElement.addAttribute(new Attribute("prefixOverrides", "and")); //$NON-NLS-1$ //$NON-NLS-2$

    ifElement.addElement(trimElement);

    trimElement.addElement(getMiddleForEachElement(null));
View Full Code Here


      sb.append(introspectedColumn.getTypeHandler());
      typeHandlerString = sb.toString();
    }

    XmlElement middleForEachElement = new XmlElement("foreach"); //$NON-NLS-1$
    middleForEachElement.addAttribute(new Attribute("collection", criteriaAttribute)); //$NON-NLS-1$
    middleForEachElement.addAttribute(new Attribute("item", "criterion")); //$NON-NLS-1$ //$NON-NLS-2$

    XmlElement chooseElement = new XmlElement("choose"); //$NON-NLS-1$
    middleForEachElement.addElement(chooseElement);

    XmlElement when = new XmlElement("when"); //$NON-NLS-1$
    when.addAttribute(new Attribute("test", "criterion.noValue")); //$NON-NLS-1$ //$NON-NLS-2$
    when.addElement(new TextElement("and ${criterion.condition}")); //$NON-NLS-1$
    chooseElement.addElement(when);

    when = new XmlElement("when"); //$NON-NLS-1$
    when.addAttribute(new Attribute("test", "criterion.singleValue")); //$NON-NLS-1$ //$NON-NLS-2$
    sb.setLength(0);
    sb.append("and ${criterion.condition} #{criterion.value"); //$NON-NLS-1$
    if (typeHandled) {
      sb.append(typeHandlerString);
    }
    sb.append('}');
    when.addElement(new TextElement(sb.toString()));
    chooseElement.addElement(when);

    when = new XmlElement("when"); //$NON-NLS-1$
    when.addAttribute(new Attribute("test", "criterion.betweenValue")); //$NON-NLS-1$ //$NON-NLS-2$
    sb.setLength(0);
    sb.append("and ${criterion.condition} #{criterion.value"); //$NON-NLS-1$
    if (typeHandled) {
      sb.append(typeHandlerString);
    }
    sb.append("} and #{criterion.secondValue"); //$NON-NLS-1$
    if (typeHandled) {
      sb.append(typeHandlerString);
    }
    sb.append('}');
    when.addElement(new TextElement(sb.toString()));
    chooseElement.addElement(when);

    when = new XmlElement("when"); //$NON-NLS-1$
    when.addAttribute(new Attribute("test", "criterion.listValue")); //$NON-NLS-1$ //$NON-NLS-2$
    when.addElement(new TextElement("and ${criterion.condition}")); //$NON-NLS-1$
    XmlElement innerForEach = new XmlElement("foreach"); //$NON-NLS-1$
    innerForEach.addAttribute(new Attribute("collection", "criterion.value")); //$NON-NLS-1$ //$NON-NLS-2$
    innerForEach.addAttribute(new Attribute("item", "listItem")); //$NON-NLS-1$ //$NON-NLS-2$
    innerForEach.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
    innerForEach.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
    innerForEach.addAttribute(new Attribute("separator", ",")); //$NON-NLS-1$ //$NON-NLS-2$
    sb.setLength(0);
    sb.append("#{listItem"); //$NON-NLS-1$
    if (typeHandled) {
      sb.append(typeHandlerString);
    }
View Full Code Here

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

    answer.addAttribute(new Attribute("id", introspectedTable.getDeleteByPrimaryKeyStatementId())); //$NON-NLS-1$
    String parameterClass;
    if (introspectedTable.getRules().generatePrimaryKeyClass()) {
      parameterClass = introspectedTable.getPrimaryKeyType();
    } else {
      parameterClass = introspectedTable.getBaseRecordType();
    }
    answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
        parameterClass));

    context.getCommentGenerator().addComment(answer);

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

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

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

    if (gk != null && gk.isPlacedBeforeInsertInIbatis2()) {
      IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
      // if the column is null, then it's a configuration error. The
      // warning has already been reported
      if (introspectedColumn != null) {
        // pre-generated key
        answer.addElement(getSelectKey(introspectedColumn, gk));
      }
    }

    StringBuilder sb = new StringBuilder();

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

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

    answer.addElement(new TextElement("values")); //$NON-NLS-1$

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

    for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
      if (introspectedColumn.isIdentity()) {
        // cannot set values on identity fields
        continue;
      }

      XmlElement insertNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
      insertNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
      insertNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
      insertNotNullElement.addElement(new TextElement(Ibatis2FormattingUtilities
          .getEscapedColumnName(introspectedColumn)));
      insertElement.addElement(insertNotNullElement);

      XmlElement valuesNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
      valuesNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
      valuesNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
      valuesNotNullElement.addElement(new TextElement(Ibatis2FormattingUtilities
          .getParameterClause(introspectedColumn)));
      valuesElement.addElement(valuesNotNullElement);
    }
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("parameterType", //$NON-NLS-1$
        parameterType.getFullyQualifiedName()));

    context.getCommentGenerator().addComment(answer);

    GeneratedKey gk = introspectedTable.getGeneratedKey();
    if (gk != null) {
      IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
      // if the column is null, then it's a configuration error. The
      // warning has already been reported
      if (introspectedColumn != null) {
        if (gk.isJdbcStandard()) {
          answer.addAttribute(new Attribute("useGeneratedKeys", "true")); //$NON-NLS-1$ //$NON-NLS-2$
          answer.addAttribute(new Attribute("keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
        } else {
          answer.addElement(getSelectKey(introspectedColumn, gk));
        }
      }
    }
View Full Code Here

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

    answer.addAttribute(new Attribute("id", introspectedTable.getCountByExampleStatementId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultClass", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$

    context.getCommentGenerator().addComment(answer);

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

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    sb.setLength(0);
    sb.append(introspectedTable.getIbatis2SqlMapNamespace());
    sb.append('.');
    sb.append(introspectedTable.getExampleWhereClauseId());
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
        sb.toString()));

    answer.addElement(includeElement);

    if (context.getPlugins().sqlMapCountByExampleElementGenerated(answer, introspectedTable)) {
View Full Code Here

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

    answer.addAttribute(new Attribute("id", introspectedTable.getUpdateByExampleStatementId())); //$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.getNonBLOBColumns().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().sqlMapUpdateByExampleWithoutBLOBsElementGenerated(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", //$NON-NLS-1$
        introspectedTable.getUpdateByExampleWithBLOBsStatementId()));

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

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

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

    context.getCommentGenerator().addComment(answer);

    XmlElement outerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    outerIterateElement.addAttribute(new Attribute("property", "oredCriteria")); //$NON-NLS-1$ //$NON-NLS-2$
    outerIterateElement.addAttribute(new Attribute("conjunction", "or")); //$NON-NLS-1$ //$NON-NLS-2$
    outerIterateElement.addAttribute(new Attribute("prepend", "where")); //$NON-NLS-1$ //$NON-NLS-2$
    outerIterateElement.addAttribute(new Attribute("removeFirstPrepend", "iterate")); //$NON-NLS-1$ //$NON-NLS-2$
    answer.addElement(outerIterateElement);

    XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
    isEqualElement.addAttribute(new Attribute("property", "oredCriteria[].valid")); //$NON-NLS-1$ //$NON-NLS-2$
    isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    outerIterateElement.addElement(isEqualElement);

    isEqualElement.addElement(new TextElement("(")); //$NON-NLS-1$

    XmlElement innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("property", "oredCriteria[].criteriaWithoutValue")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addElement(new TextElement("$oredCriteria[].criteriaWithoutValue[]$")); //$NON-NLS-1$
    isEqualElement.addElement(innerIterateElement);

    innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("property", "oredCriteria[].criteriaWithSingleValue")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement
        .addElement(new TextElement(
            "$oredCriteria[].criteriaWithSingleValue[].condition$ #oredCriteria[].criteriaWithSingleValue[].value#")); //$NON-NLS-1$
    isEqualElement.addElement(innerIterateElement);

    innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("property", "oredCriteria[].criteriaWithListValue")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addElement(new TextElement("$oredCriteria[].criteriaWithListValue[].condition$")); //$NON-NLS-1$
    XmlElement innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
        "oredCriteria[].criteriaWithListValue[].values")); //$NON-NLS-1$
    innerInnerIterateElement.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
    innerInnerIterateElement.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
    innerInnerIterateElement.addAttribute(new Attribute("conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$
    innerInnerIterateElement.addElement(new TextElement("#oredCriteria[].criteriaWithListValue[].values[]#")); //$NON-NLS-1$
    innerIterateElement.addElement(innerInnerIterateElement);
    isEqualElement.addElement(innerIterateElement);

    innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
    innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("property", "oredCriteria[].criteriaWithBetweenValue")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
    innerIterateElement.addElement(new TextElement("$oredCriteria[].criteriaWithBetweenValue[].condition$")); //$NON-NLS-1$
    innerIterateElement.addElement(new TextElement("#oredCriteria[].criteriaWithBetweenValue[].values[0]# and")); //$NON-NLS-1$
    innerIterateElement.addElement(new TextElement("#oredCriteria[].criteriaWithBetweenValue[].values[1]#")); //$NON-NLS-1$
    isEqualElement.addElement(innerIterateElement);

    // if any of the columns have a user defined type handler, then we need
    // to add additional inner iterate elements that specify the type
    // handler
    for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
      if (stringHasValue(introspectedColumn.getTypeHandler())) {
        // name the property based on the column name, then
        // add the type handler to the parameter declaration
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$

        sb1.append("oredCriteria[]."); //$NON-NLS-1$
        sb1.append(introspectedColumn.getJavaProperty());
        sb1.append("CriteriaWithSingleValue"); //$NON-NLS-1$

        innerIterateElement.addAttribute(new Attribute("property", sb1.toString())); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

        sb2.append(sb1);

        sb1.insert(0, '$');
        sb1.append("[].condition$ ");//$NON-NLS-1$

        sb2.insert(0, '#');
        sb2.append("[].value,handler=");//$NON-NLS-1$
        sb2.append(introspectedColumn.getTypeHandler());
        sb2.append('#');

        sb1.append(sb2);

        innerIterateElement.addElement(new TextElement(sb1.toString()));
        isEqualElement.addElement(innerIterateElement);

        sb1.setLength(0);
        sb2.setLength(0);
        sb1.append("oredCriteria[]."); //$NON-NLS-1$
        sb1.append(introspectedColumn.getJavaProperty());
        sb1.append("CriteriaWithListValue"); //$NON-NLS-1$

        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("property", sb1.toString())); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

        sb2.append('$');
        sb2.append(sb1);
        sb2.append("[].condition$"); //$NON-NLS-1$

        innerIterateElement.addElement(new TextElement(sb2.toString()));

        sb2.setLength(0);
        sb2.append(sb1);
        sb2.append("[].values"); //$NON-NLS-1$

        innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
            sb2.toString()));
        innerInnerIterateElement.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
        innerInnerIterateElement.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
        innerInnerIterateElement.addAttribute(new Attribute("conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$

        sb2.setLength(0);
        sb2.append('#');
        sb2.append(sb1);
        sb2.append("[].values[],handler="); //$NON-NLS-1$
        sb2.append(introspectedColumn.getTypeHandler());
        sb2.append('#');

        innerInnerIterateElement.addElement(new TextElement(sb2.toString()));
        innerIterateElement.addElement(innerInnerIterateElement);
        isEqualElement.addElement(innerIterateElement);

        sb1.setLength(0);
        sb2.setLength(0);
        sb1.append("oredCriteria[]."); //$NON-NLS-1$
        sb1.append(introspectedColumn.getJavaProperty());
        sb1.append("CriteriaWithBetweenValue"); //$NON-NLS-1$

        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("property", sb1.toString())); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

        sb2.append('$');
        sb2.append(sb1);
        sb2.append("[].condition$"); //$NON-NLS-1$
View Full Code Here

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

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