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


Java IntrospectedColumn.getJdbcType方法代码示例

本文整理汇总了Java中org.mybatis.generator.api.IntrospectedColumn.getJdbcType方法的典型用法代码示例。如果您正苦于以下问题:Java IntrospectedColumn.getJdbcType方法的具体用法?Java IntrospectedColumn.getJdbcType怎么用?Java IntrospectedColumn.getJdbcType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.generator.api.IntrospectedColumn的用法示例。


在下文中一共展示了IntrospectedColumn.getJdbcType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateJdbcTypeName

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
public String calculateJdbcTypeName(IntrospectedColumn introspectedColumn) {
	String answer;
	JdbcTypeInformation jdbcTypeInformation = typeMap
			.get(introspectedColumn.getJdbcType());

	if (jdbcTypeInformation == null) {
		switch (introspectedColumn.getJdbcType()) {
		case Types.DECIMAL:
			answer = "DECIMAL"; //$NON-NLS-1$
			break;
		case Types.NUMERIC:
			answer = "NUMERIC"; //$NON-NLS-1$
			break;
		default:
			answer = null;
			break;
		}
	} else {
		answer = jdbcTypeInformation.getJdbcTypeName();
	}

	return answer;
}
 
开发者ID:ling49043171,项目名称:mark-mybatis-generator,代码行数:24,代码来源:Mysql2JavaTypeResolver.java

示例2: calculateJdbcTypeName

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
public String calculateJdbcTypeName(IntrospectedColumn introspectedColumn) {
	String answer;
	JdbcTypeInformation jdbcTypeInformation = typeMap
			.get(introspectedColumn.getJdbcType());

	if (jdbcTypeInformation == null) {
		switch (introspectedColumn.getJdbcType()) {
		case Types.DECIMAL:
			answer = "DECIMAL"; //$NON-NLS-1$
			break;
		case Types.NUMERIC:
			answer = "NUMERIC"; //$NON-NLS-1$
			break;
		default:
			answer = introspectedColumn.getJdbcTypeName();
			break;
		}
	} else {
		answer = jdbcTypeInformation.getJdbcTypeName();
	}

	return answer;
}
 
开发者ID:ling49043171,项目名称:mark-mybatis-generator,代码行数:24,代码来源:OracleJavaTypeResolver.java

示例3: overrideDefaultType

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
protected FullyQualifiedJavaType overrideDefaultType(IntrospectedColumn column, FullyQualifiedJavaType defaultType) {
    FullyQualifiedJavaType answer = defaultType;
    
    switch (column.getJdbcType()) {
    case Types.BIT:
        answer = calculateBitReplacement(column, defaultType);
        break;
    case Types.DECIMAL:
    case Types.NUMERIC:
        answer = calculateBigDecimalReplacement(column, defaultType);
        break;
    }

    return answer;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:16,代码来源:JavaTypeResolverDefaultImpl.java

示例4: modelGetterMethodGenerated

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
/**
 * 解析处理注释,增加 getXxxText() 方法
 *    注释格式范例:
 *      @enum 0: 有效期; 1: 无效
 */
@Override
public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass,
                                          IntrospectedColumn introspectedColumn,
                                          IntrospectedTable introspectedTable,
                                          ModelClassType modelClassType) {

    String remarks = introspectedColumn.getRemarks();
    int jdbcType = introspectedColumn.getJdbcType();

    remarks = StringUtils.trimToNull(remarks);

    if (remarks == null) {
        return true;
    }

    if (!remarks.contains("@enum")) {
        return true;
    }

    String annotation = remarks.substring(remarks.indexOf("@enum") + 5);
    String[] items = StringUtils.split(annotation, ';');

    StringBuilder mapInitSb = new StringBuilder("new HashMap<Object, String>(){{");
    for (String item : items) {
        if (!item.contains(":")) {
            continue;
        }
        String[] kv = item.split(":");
        String k = StringUtils.trim(kv[0]);
        String v = StringUtils.trim(kv[1]);
        mapInitSb.append("put(");
        if (jdbcType == Types.TINYINT) {
            mapInitSb.append("(byte)");
        }
        mapInitSb.append(k).append(",")
                .append("\"").append(v).append("\");");
    }
    mapInitSb.append("}}");

    // 增加常量
    String fieldName = String.format("%sMap", introspectedColumn.getJavaProperty());

    Field field = new Field(
            fieldName,
            new FullyQualifiedJavaType("java.util.HashMap<Object, String>")
    );
    field.setVisibility(JavaVisibility.PRIVATE);
    field.setStatic(true);
    field.setFinal(true);
    field.setInitializationString(mapInitSb.toString());

    topLevelClass.addField(field);


    // 增加方法
    Method textMethod = new Method(String.format("%sText", method.getName()));
    textMethod.setReturnType(new FullyQualifiedJavaType(String.class.getCanonicalName()));
    textMethod.setVisibility(JavaVisibility.PUBLIC);
    if (jdbcType == Types.TINYINT) {
        textMethod.addBodyLine(String.format("return %s.get((byte)this.%s);", fieldName, introspectedColumn.getJavaProperty()));
    } else {
        textMethod.addBodyLine(String.format("return %s.get(this.%s);", fieldName, introspectedColumn.getJavaProperty()));
    }

    remarks = remarks.replaceAll("\n", "\\\\n").replaceAll("\"", "\\\\\"");
    textMethod.addAnnotation(
        String.format("@ApiModelProperty(value = \"%s\")", remarks)
    );

    topLevelClass.addImportedType(new FullyQualifiedJavaType(HashMap.class.getCanonicalName()));
    topLevelClass.addMethod(textMethod);

    return true;
}
 
开发者ID:yinheli,项目名称:mybatis-generator-tool,代码行数:80,代码来源:StatusTextPlugin.java

示例5: overrideDefaultType

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
protected FullyQualifiedJavaType overrideDefaultType(IntrospectedColumn column, FullyQualifiedJavaType defaultType) {
    FullyQualifiedJavaType answer = defaultType;

    switch (column.getJdbcType()) {
        case Types.BIT:
            answer = calculateBitReplacement(column, defaultType);
            break;
        case Types.DECIMAL:
        case Types.NUMERIC:
            answer = calculateBigDecimalReplacement(column, defaultType);
            break;
    }

    return answer;
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:16,代码来源:CustomJavaTypeResolver.java

示例6: addGetterComment

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
public void addGetterComment(Method method,
        IntrospectedTable introspectedTable,
        IntrospectedColumn introspectedColumn) {
    if (suppressAllComments) {
        return;
    }

    StringBuilder sb = new StringBuilder();
    if(introspectedColumn.getJdbcType() == 93) {
    	sb.append("@JsonFormat(locale = \"zh\", timezone = \"GMT+8\", pattern = \"yyyy-MM-dd HH:mm:ss\")");
    }
    
    if(sb.length() > 0) {
    	method.addJavaDocLine(sb.toString()); 
    }

    /*method.addJavaDocLine("/**"); 
    method.addJavaDocLine(" * This method was generated by MyBatis Generator."); 
    sb.append(" * This method returns the value of the database column "); 
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());
    method.addJavaDocLine(" *"); 
    sb.setLength(0);
    sb.append(" * @return the value of "); 
    sb.append(introspectedTable.getFullyQualifiedTable());
    sb.append('.');
    sb.append(introspectedColumn.getActualColumnName());
    method.addJavaDocLine(sb.toString());
    addJavadocTag(method, false);*/

    //method.addJavaDocLine(" */"); 
}
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:35,代码来源:DefaultCommentGenerator.java

示例7: addFieldComment

import org.mybatis.generator.api.IntrospectedColumn; //导入方法依赖的package包/类
public void addFieldComment(Field field,
         IntrospectedTable introspectedTable,
         IntrospectedColumn introspectedColumn) {
     if (suppressAllComments) {
         return;
     }
     
     //字段备注信息
     String remarks = introspectedColumn.getRemarks();
     field.addJavaDocLine("@ApiModelProperty(value = \"" + remarks + "\")");
     
     //当字段数据类型为date时添加日期注释
     StringBuffer sb = new StringBuffer();
     if(introspectedColumn.getJdbcType() == 93) {
sb.append("@DateTimeFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")");
     }
     
     if(sb.length() > 0) {
     	field.addJavaDocLine(sb.toString());
     }
     

     /*field.addJavaDocLine("/**"); 
     if (addRemarkComments && StringUtility.stringHasValue(remarks)) {
         field.addJavaDocLine(" * Database Column Remarks:");
         String[] remarkLines = remarks.split(System.getProperty("line.separator"));  
         for (String remarkLine : remarkLines) {
             field.addJavaDocLine(" *   " + remarkLine);  
         }
     }

     field.addJavaDocLine(" *"); 
     field.addJavaDocLine(" * This field was generated by MyBatis Generator."); 

     StringBuilder sb = new StringBuilder();
     sb.append(" * This field corresponds to the database column "); 
     sb.append(introspectedTable.getFullyQualifiedTable());
     sb.append('.');
     sb.append(introspectedColumn.getActualColumnName());
     field.addJavaDocLine(sb.toString());
     addJavadocTag(field, false);*/

     //field.addJavaDocLine(" */"); 
 }
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:45,代码来源:DefaultCommentGenerator.java


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