本文整理汇总了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);
}
}
}
}
}
示例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;
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}