当前位置: 首页>>代码示例>>Java>>正文


Java MyBatis3FormattingUtilities类代码示例

本文整理汇总了Java中org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities的典型用法代码示例。如果您正苦于以下问题:Java MyBatis3FormattingUtilities类的具体用法?Java MyBatis3FormattingUtilities怎么用?Java MyBatis3FormattingUtilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MyBatis3FormattingUtilities类属于org.mybatis.generator.codegen.mybatis3包,在下文中一共展示了MyBatis3FormattingUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNoValueMethod

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
private Method getNoValueMethod(IntrospectedColumn introspectedColumn,
        String nameFragment, String operator) {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    StringBuilder sb = new StringBuilder();
    sb.append(introspectedColumn.getJavaProperty());
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    sb.insert(0, "and"); //$NON-NLS-1$
    sb.append(nameFragment);
    method.setName(sb.toString());
    method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
    sb.setLength(0);
    sb.append("addCriterion(\""); //$NON-NLS-1$
    sb.append(MyBatis3FormattingUtilities
            .getAliasedActualColumnName(introspectedColumn));
    sb.append(' ');
    sb.append(operator);
    sb.append("\");"); //$NON-NLS-1$
    method.addBodyLine(sb.toString());
    method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

    return method;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:24,代码来源:ExampleGenerator.java

示例2: addResultMapElements

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
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);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:23,代码来源:ResultMapWithBLOBsElementGenerator.java

示例3: generateSqlBaseColumns

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
/**
 * 生成包含全部列的 sql 元素
 */
private void generateSqlBaseColumns(Document document, IntrospectedTable introspectedTable) {
    // 新建 sql 元素标签
    XmlElement sqlElement = new XmlElement("sql");
    // 新建 sql 元素属性
    Attribute attr = new Attribute("id", id);
    sqlElement.addAttribute(attr);
    // 新建 sql 元素内容,填写注释
    sqlElement.addElement(new TextElement(Constants.WARNING));
    // 获取全部列名称
    StringBuilder columnsBuilder = new StringBuilder();
    List<IntrospectedColumn> columnList = introspectedTable.getAllColumns();
    for (IntrospectedColumn column : columnList) {
        columnsBuilder.append(MyBatis3FormattingUtilities.getSelectListPhrase(column)).append(", ");
    }
    // 删除最后一个逗号
    String columns = columnsBuilder.substring(0, columnsBuilder.length() - 2);
    // 新建 sql 元素内容,填写列名称
    sqlElement.addElement(new TextElement(columns));
    // 将 sql 元素放到根元素下
    XmlElement rootElement = document.getRootElement();
    rootElement.addElement(new TextElement(""));
    rootElement.addElement(sqlElement);
    rootElement.addElement(new TextElement(""));
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:28,代码来源:MapperSqlMapConfigPlugin.java

示例4: addResultMapElements

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
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);
    }
}
 
开发者ID:funny5258,项目名称:autocode,代码行数:17,代码来源:ResultMapWithBLOBsElementGenerator.java

示例5: generateParameterForSet

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void generateParameterForSet(String fieldPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement dynamicElement) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append(MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
    sb.append(" = ");
    sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix));
    sb.append(',');

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  dynamicElement.addElement(trimElement);
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:18,代码来源:AbstractXmbgPlugin.java

示例6: generateParametersSeparateByComma

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void generateParametersSeparateByComma(String fieldPrefix, boolean ifNullCheck, boolean withParenthesis, List<IntrospectedColumn> columns, XmlElement parent) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));
  if (withParenthesis) {
    trimElement.addAttribute(new Attribute("prefix", "("));
    trimElement.addAttribute(new Attribute("suffix", ")"));
  }

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix));
    sb.append(",");

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }
  parent.addElement(trimElement);
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:19,代码来源:AbstractXmbgPlugin.java

示例7: generateActualColumnNamesWithParenthesis

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void generateActualColumnNamesWithParenthesis(String fieldPrefix, String columnPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement parent) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));
  trimElement.addAttribute(new Attribute("prefix", "("));
  trimElement.addAttribute(new Attribute("suffix", ")"));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append((columnPrefix == null ? "" : columnPrefix) + MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
    sb.append(",");

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  parent.addElement(trimElement);
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:18,代码来源:AbstractXmbgPlugin.java

示例8: generateWhereConditions

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void generateWhereConditions(String fieldPrefix, String columnPrefix, boolean ifNullCheck, List<IntrospectedColumn> columns, XmlElement parent) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : columns) {
    sb.setLength(0);
    sb.append((columnPrefix == null ? "" : columnPrefix) + MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
    sb.append(" = ");
    sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, fieldPrefix));
    sb.append(",");

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  XmlElement where = new XmlElement("where");
  where.addElement(trimElement);
  parent.addElement(where);
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:20,代码来源:AbstractXmbgPlugin.java

示例9: generateCopyForSetByPrefix

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void generateCopyForSetByPrefix(String fieldPrefix, String leftPrefix, String rightPrefix, boolean ifNullCheck, IntrospectedTable introspectedTable, XmlElement dynamicElement) {
  XmlElement trimElement = new XmlElement("trim");
  trimElement.addAttribute(new Attribute("suffixOverrides", ","));

  StringBuilder sb = new StringBuilder();
  for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {

    sb.setLength(0);
    String columnName = MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn);
    sb.append(leftPrefix + columnName);
    sb.append(" = ");
    sb.append(rightPrefix + columnName);
    sb.append(',');

    doIfNullCheck(fieldPrefix, ifNullCheck, trimElement, sb, introspectedColumn);
  }

  dynamicElement.addElement(trimElement);
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:20,代码来源:HsqldbUpsertPlugin.java

示例10: checkAndReplaceInput

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
protected void checkAndReplaceInput(List<IntrospectedColumn> columns, TextElement te) {
  String sql = te.getContent();
  for(IntrospectedColumn column : columns){
  	if(column.getFullyQualifiedJavaType().getShortName().equals("Geometry")){
  		String paramStr = MyBatis3FormattingUtilities.getParameterClause(column);
  		sql = StringUtils.replace(sql, paramStr, "ST_GeomFromText(" + paramStr + ","+srid+")"); //replace no prefix geo relate column
  		paramStr = MyBatis3FormattingUtilities.getParameterClause(column, "record.");
  		sql = StringUtils.replace(sql, paramStr, "ST_GeomFromText(" + paramStr + ","+srid+")"); //replace mbg generate prefix geo relate column
  		paramStr = MyBatis3FormattingUtilities.getParameterClause(column, "item.");
  		sql = StringUtils.replace(sql, paramStr, "ST_GeomFromText(" + paramStr + ","+srid+")"); //replace mbg batch plugin generate prefix geo relate column				
//				System.out.println();
//				System.out.println(sql);
  	}
  }
  try {
    FieldUtils.writeDeclaredField(te, "content", sql, true);
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  }
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:21,代码来源:PostgisGeoPlugin.java

示例11: getNoValueMethod

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
private Method getNoValueMethod(IntrospectedColumn introspectedColumn, String nameFragment, String operator) {
	Method method = new Method();
	method.setVisibility(JavaVisibility.PUBLIC);
	StringBuilder sb = new StringBuilder();
	sb.append(introspectedColumn.getJavaProperty());
	sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
	sb.insert(0, "and"); //$NON-NLS-1$
	sb.append(nameFragment);
	method.setName(sb.toString());
	method.setReturnType(FullyQualifiedJavaType.getCriteriaInstance());
	sb.setLength(0);
	sb.append("addCriterion(\""); //$NON-NLS-1$
	sb.append(MyBatis3FormattingUtilities.getAliasedActualColumnName(introspectedColumn));
	sb.append(' ');
	sb.append(operator);
	sb.append("\");"); //$NON-NLS-1$
	method.addBodyLine(sb.toString());
	method.addBodyLine("return (Criteria) this;"); //$NON-NLS-1$

	return method;
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:22,代码来源:ExampleGenerator.java

示例12: addResultMapElements

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
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);
	}
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:17,代码来源:ResultMapWithBLOBsElementGenerator.java

示例13: addElements

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:37,代码来源:BlobColumnListElementGenerator.java

示例14: addElements

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
@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(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().sqlMapBaseColumnListElementGenerated(
            answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:36,代码来源:BaseColumnListElementGenerator.java

示例15: generateCommColumnsSelective

import org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities; //导入依赖的package包/类
/**
 * 通用遍历columns
 * @param columns
 * @param prefix
 * @param bracket
 * @param type    1:key,2:value,3:set
 * @return
 */
private static XmlElement generateCommColumnsSelective(List<IntrospectedColumn> columns, String prefix, boolean bracket, int type) {
    XmlElement eleTrim = new XmlElement("trim");
    if (bracket) {
        eleTrim.addAttribute(new Attribute("prefix", "("));
        eleTrim.addAttribute(new Attribute("suffix", ")"));
        eleTrim.addAttribute(new Attribute("suffixOverrides", ","));
    } else {
        eleTrim.addAttribute(new Attribute("suffixOverrides", ","));
    }

    for (IntrospectedColumn introspectedColumn : columns) {
        XmlElement eleIf = new XmlElement("if");
        eleIf.addAttribute(new Attribute("test", introspectedColumn.getJavaProperty(prefix) + " != null"));

        switch (type) {
            case 3:
                eleIf.addElement(new TextElement(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + " = " + MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix) + ","));
                break;
            case 2:
                eleIf.addElement(new TextElement(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, prefix) + ","));
                break;
            case 1:
                eleIf.addElement(new TextElement(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn) + ","));
                break;
        }

        eleTrim.addElement(eleIf);
    }

    return eleTrim;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:40,代码来源:XmlElementGeneratorTools.java


注:本文中的org.mybatis.generator.codegen.mybatis3.MyBatis3FormattingUtilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。