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


Java GeneratedKey类代码示例

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


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

示例1: calculateIdentityColumns

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
/**
 * Calculate identity columns.
 *
 * @param tc
 *            the tc
 * @param columns
 *            the columns
 */
private void calculateIdentityColumns(TableConfiguration tc,
        Map<ActualTableName, List<IntrospectedColumn>> columns) {
    GeneratedKey gk = tc.getGeneratedKey();
    if (gk == null) {
        // no generated key, then no identity or sequence columns
        return;
    }
    
    for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns
            .entrySet()) {
        for (IntrospectedColumn introspectedColumn : entry.getValue()) {
            if (isMatchedColumn(introspectedColumn, gk)) {
                if (gk.isIdentity() || gk.isJdbcStandard()) {
                    introspectedColumn.setIdentity(true);
                    introspectedColumn.setSequenceColumn(false);
                } else {
                    introspectedColumn.setIdentity(false);
                    introspectedColumn.setSequenceColumn(true);
                }
            }
        }
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:32,代码来源:DatabaseIntrospector.java

示例2: getSelectKey

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
/**
 * This method should return an XmlElement for the select key used to
 * automatically generate keys.
 * 
 * @param introspectedColumn
 *            the column related to the select key statement
 * @param generatedKey
 *            the generated key for the current table
 * @return the selectKey element
 */
protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn,
        GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn
            .getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultClass", identityColumnType)); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
    if (stringHasValue(generatedKey.getType())) {
        answer.addAttribute(new Attribute("type", generatedKey.getType())); //$NON-NLS-1$  
    }
    answer
            .addElement(new TextElement(generatedKey
                    .getRuntimeSqlStatement()));

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

示例3: addGeneratedKeyAnnotation

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
protected void addGeneratedKeyAnnotation(Method method, GeneratedKey gk) {
    StringBuilder sb = new StringBuilder();
    IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
    if (introspectedColumn != null) {
        if (gk.isJdbcStandard()) {
            sb.append("@Options(useGeneratedKeys=true,keyProperty=\""); //$NON-NLS-1$
            sb.append(introspectedColumn.getJavaProperty());
            sb.append("\")"); //$NON-NLS-1$
            method.addAnnotation(sb.toString());
        } else {
            FullyQualifiedJavaType fqjt = introspectedColumn.getFullyQualifiedJavaType();
            sb.append("@SelectKey(statement=\""); //$NON-NLS-1$
            sb.append(gk.getRuntimeSqlStatement());
            sb.append("\", keyProperty=\""); //$NON-NLS-1$
            sb.append(introspectedColumn.getJavaProperty());
            sb.append("\", before="); //$NON-NLS-1$
            sb.append(gk.isIdentity() ? "false" : "true"); //$NON-NLS-1$ //$NON-NLS-2$
            sb.append(", resultType="); //$NON-NLS-1$
            sb.append(fqjt.getShortName());
            sb.append(".class)"); //$NON-NLS-1$
            method.addAnnotation(sb.toString());
        }
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:25,代码来源:AbstractJavaMapperMethodGenerator.java

示例4: addMapperAnnotations

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
@Override
public void addMapperAnnotations(Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    StringBuilder sb = new StringBuilder();
    sb.append("@InsertProvider(type="); //$NON-NLS-1$
    sb.append(fqjt.getShortName());
    sb.append(".class, method=\""); //$NON-NLS-1$
    sb.append(introspectedTable.getInsertSelectiveStatementId());
    sb.append("\")"); //$NON-NLS-1$
    
    method.addAnnotation(sb.toString());

    GeneratedKey gk = introspectedTable.getGeneratedKey();
    if (gk != null) {
        addGeneratedKeyAnnotation(method, gk);
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:18,代码来源:AnnotatedInsertSelectiveMethodGenerator.java

示例5: getSelectKey

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
/**
 * This method should return an XmlElement for the select key used to
 * automatically generate keys.
 * 
 * @param introspectedColumn
 *            the column related to the select key statement
 * @param generatedKey
 *            the generated key for the current table
 * @return the selectKey element
 */
protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn,
        GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn
            .getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", identityColumnType)); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
            "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("order", //$NON-NLS-1$
            generatedKey.getMyBatis3Order())); 
    
    answer.addElement(new TextElement(generatedKey
                    .getRuntimeSqlStatement()));

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

示例6: getSelectKey

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
/**
 * This method should return an XmlElement for the select key used to
 * automatically generate keys.
 * @param introspectedColumn the column related to the select key statement
 * @param generatedKey       the generated key for the current table
 * @return the selectKey element
 */
public static Element getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) {
    String identityColumnType = introspectedColumn
            .getFullyQualifiedJavaType().getFullyQualifiedName();

    XmlElement answer = new XmlElement("selectKey");
    answer.addAttribute(new Attribute("resultType", identityColumnType));
    answer.addAttribute(new Attribute(
            "keyProperty", introspectedColumn.getJavaProperty()));
    answer.addAttribute(new Attribute("order",
            generatedKey.getMyBatis3Order()));

    answer.addElement(new TextElement(generatedKey
            .getRuntimeSqlStatement()));

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

示例7: addMapperAnnotations

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
@Override
public void addMapperAnnotations(Interface interfaze, Method method) {
    FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(introspectedTable.getMyBatis3SqlProviderType());
    interfaze.addImportedType(new FullyQualifiedJavaType("org.apache.ibatis.annotations.InsertProvider")); //$NON-NLS-1$
    StringBuilder sb = new StringBuilder();
    sb.append("@InsertProvider(type="); //$NON-NLS-1$
    sb.append(fqjt.getShortName());
    sb.append(".class, method=\""); //$NON-NLS-1$
    sb.append(introspectedTable.getInsertSelectiveStatementId());
    sb.append("\")"); //$NON-NLS-1$
    
    method.addAnnotation(sb.toString());

    GeneratedKey gk = introspectedTable.getGeneratedKey();
    if (gk != null) {
        addGeneratedKeyAnnotation(interfaze, method, gk);
    }
}
 
开发者ID:xiachengwei5,项目名称:org.mybatis.generator.core-1.3.5,代码行数:19,代码来源:AnnotatedInsertSelectiveMethodGenerator.java

示例8: calculateIdentityColumns

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
private void calculateIdentityColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) {
    GeneratedKey gk = tc.getGeneratedKey();
    if (gk == null) {
        // no generated key, then no identity or sequence columns
        return;
    }

    for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
        for (IntrospectedColumn introspectedColumn : entry.getValue()) {
            if (isMatchedColumn(introspectedColumn, gk)) {
                if (gk.isIdentity() || gk.isJdbcStandard()) {
                    introspectedColumn.setIdentity(true);
                    introspectedColumn.setSequenceColumn(false);
                } else {
                    introspectedColumn.setIdentity(false);
                    introspectedColumn.setSequenceColumn(true);
                }
            }
        }
    }
}
 
开发者ID:funny5258,项目名称:autocode,代码行数:22,代码来源:DatabaseIntrospector.java

示例9: calculateIdentityColumns

import org.mybatis.generator.config.GeneratedKey; //导入依赖的package包/类
private void calculateIdentityColumns(TableConfiguration tc,
        Map<ActualTableName, List<IntrospectedColumn>> columns) {
    GeneratedKey gk = tc.getGeneratedKey();
    if (gk == null) {
        // no generated key, then no identity or sequence columns
        return;
    }
    
    for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns
            .entrySet()) {
        for (IntrospectedColumn introspectedColumn : entry.getValue()) {
            if (isMatchedColumn(introspectedColumn, gk)) {
                if (gk.isIdentity() || gk.isJdbcStandard()) {
                    introspectedColumn.setIdentity(true);
                    introspectedColumn.setSequenceColumn(false);
                } else {
                    introspectedColumn.setIdentity(false);
                    introspectedColumn.setSequenceColumn(true);
                }
            }
        }
    }
}
 
开发者ID:handosme,项目名称:mybatis-generator-plus,代码行数:24,代码来源:DatabaseIntrospector.java


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