本文整理汇总了Java中org.mybatis.generator.config.TableConfiguration.getGeneratedKey方法的典型用法代码示例。如果您正苦于以下问题:Java TableConfiguration.getGeneratedKey方法的具体用法?Java TableConfiguration.getGeneratedKey怎么用?Java TableConfiguration.getGeneratedKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.config.TableConfiguration
的用法示例。
在下文中一共展示了TableConfiguration.getGeneratedKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateIdentityColumns
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的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: calculateIdentityColumns
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的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);
}
}
}
}
}
示例3: calculateIdentityColumns
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的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);
}
}
}
}
}
示例4: calculateIdentityColumns
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的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);
}
}
}
}
}
示例5: reportIntrospectionWarnings
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* Report introspection warnings.
*
* @param introspectedTable
* the introspected table
* @param tableConfiguration
* the table configuration
* @param table
* the table
*/
private void reportIntrospectionWarnings(
IntrospectedTable introspectedTable,
TableConfiguration tableConfiguration, FullyQualifiedTable table) {
// make sure that every column listed in column overrides
// actually exists in the table
for (ColumnOverride columnOverride : tableConfiguration
.getColumnOverrides()) {
if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
warnings.add(getString("Warning.3", //$NON-NLS-1$
columnOverride.getColumnName(), table.toString()));
}
}
// make sure that every column listed in ignored columns
// actually exists in the table
for (String string : tableConfiguration.getIgnoredColumnsInError()) {
warnings.add(getString("Warning.4", //$NON-NLS-1$
string, table.toString()));
}
GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
if (generatedKey != null
&& introspectedTable.getColumn(generatedKey.getColumn()) == null) {
if (generatedKey.isIdentity()) {
warnings.add(getString("Warning.5", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
} else {
warnings.add(getString("Warning.6", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
}
}
for (IntrospectedColumn ic : introspectedTable.getAllColumns()) {
if (JavaReservedWords.containsWord(ic.getJavaProperty())) {
warnings.add(getString("Warning.26", //$NON-NLS-1$
ic.getActualColumnName(), table.toString()));
}
}
}
示例6: modelFieldGenerated
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
@Override
public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn,
IntrospectedTable introspectedTable, ModelClassType modelClassType) {
String columnName = introspectedColumn.getActualColumnName();
String columnNameStr = new StringBuilder("\"").append(columnName).append("\"").toString();
TableConfiguration tabConfig = introspectedTable.getTableConfiguration();
//primaryKey
List<IntrospectedColumn> primaryKeys = introspectedTable.getPrimaryKeyColumns();
for (IntrospectedColumn primaryColumn : primaryKeys) {
if(primaryColumn.equals(introspectedColumn)){
field.addAnnotation("@Id");
field.addAnnotation("@GeneratedValue(generator="+columnNameStr+")");
GeneratedKey genKey = tabConfig.getGeneratedKey();
if(introspectedColumn.isIdentity()){
}else if(introspectedColumn.isSequenceColumn()){
field.addAnnotation("@SequenceGenerator(name="+columnNameStr+",sequenceName=\"" + genKey.getRuntimeSqlStatement() + "\")");
}
break;
}
}
//Column mapping
field.addAnnotation("@Column(name="+columnNameStr+")");
return true;
}
示例7: reportIntrospectionWarnings
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
private void reportIntrospectionWarnings(
IntrospectedTable introspectedTable,
TableConfiguration tableConfiguration, FullyQualifiedTable table) {
// make sure that every column listed in column overrides
// actually exists in the table
for (ColumnOverride columnOverride : tableConfiguration
.getColumnOverrides()) {
if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
warnings.add(getString("Warning.3", //$NON-NLS-1$
columnOverride.getColumnName(), table.toString()));
}
}
// make sure that every column listed in ignored columns
// actually exists in the table
for (String string : tableConfiguration.getIgnoredColumnsInError()) {
warnings.add(getString("Warning.4", //$NON-NLS-1$
string, table.toString()));
}
GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
if (generatedKey != null
&& introspectedTable.getColumn(generatedKey.getColumn()) == null) {
if (generatedKey.isIdentity()) {
warnings.add(getString("Warning.5", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
} else {
warnings.add(getString("Warning.6", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
}
}
}
示例8: reportIntrospectionWarnings
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
private void reportIntrospectionWarnings(IntrospectedTable introspectedTable,
TableConfiguration tableConfiguration, FullyQualifiedTable table) {
// make sure that every column listed in column overrides
// actually exists in the table
for (ColumnOverride columnOverride : tableConfiguration.getColumnOverrides()) {
if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
warnings.add(getString("Warning.3", //$NON-NLS-1$
columnOverride.getColumnName(), table.toString()));
}
}
// make sure that every column listed in ignored columns
// actually exists in the table
for (String string : tableConfiguration.getIgnoredColumnsInError()) {
warnings.add(getString("Warning.4", //$NON-NLS-1$
string, table.toString()));
}
GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
if (generatedKey != null && introspectedTable.getColumn(generatedKey.getColumn()) == null) {
if (generatedKey.isIdentity()) {
warnings.add(getString("Warning.5", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
} else {
warnings.add(getString("Warning.6", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
}
}
}