本文整理了Java中org.mybatis.generator.config.TableConfiguration
类的一些代码示例,展示了TableConfiguration
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableConfiguration
类的具体详情如下:
包路径:org.mybatis.generator.config.TableConfiguration
类名称:TableConfiguration
暂无
代码示例来源:origin: abel533/Mapper
if (StringUtility.stringContainsSpace(column) || introspectedTable.getTableConfiguration().isAllColumnDelimitingEnabled()) {
column = introspectedColumn.getContext().getBeginningDelimiter()
+ column
if ("JDBC".equals(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement())) {
field.addAnnotation("@GeneratedValue(generator = \"JDBC\")");
} else {
String sql = MessageFormat.format(introspectedTable.getTableConfiguration().getGeneratedKey().getRuntimeSqlStatement(), tableName, tableName.toUpperCase());
field.addAnnotation("@GeneratedValue(strategy = GenerationType.IDENTITY, generator = \"" + sql + "\")");
代码示例来源:origin: huzhicheng/kite-mybatis-builder
private void importTableList(String tableList,String entityList,Context context){
String[] tableArray = tableList.split(",");
String[] entityArray = entityList.split(",");
for(int i = 0;i<tableArray.length;i++){
TableConfiguration t = new TableConfiguration(context);
t.setSchema("root");
t.setTableName(tableArray[i]);
t.setDomainObjectName(entityArray[i]);
t.addProperty("useActualColumnNames","false");
t.setGeneratedKey(new GeneratedKey("id","MySql",true,"post"));
context.addTableConfiguration(t);
}
}
代码示例来源:origin: roncoo/roncoo-mybatis-generator
private void parseTable(Context context, Node node) {
TableConfiguration tc = new TableConfiguration(context);
context.addTableConfiguration(tc);
tc.setCatalog(catalog);
tc.setSchema(schema);
tc.setTableName(tableName);
tc.setDomainObjectName(domainObjectName);
tc.setAlias(alias);
tc.setInsertStatementEnabled(isTrue(enableInsert));
tc.setSelectByPrimaryKeyStatementEnabled(isTrue(enableSelectByPrimaryKey));
tc.setSelectByExampleStatementEnabled(isTrue(enableSelectByExample));
tc.setUpdateByPrimaryKeyStatementEnabled(isTrue(enableUpdateByPrimaryKey));
tc.setDeleteByPrimaryKeyStatementEnabled(isTrue(enableDeleteByPrimaryKey));
tc.setDeleteByExampleStatementEnabled(isTrue(enableDeleteByExample));
tc.setCountByExampleStatementEnabled(isTrue(enableCountByExample));
tc.setUpdateByExampleStatementEnabled(isTrue(enableUpdateByExample));
代码示例来源:origin: cxjava/mybatis-generator-core
private List<IntrospectedTable> calculateIntrospectedTables(TableConfiguration tc,
Map<ActualTableName, List<IntrospectedColumn>> columns) {
boolean delimitIdentifiers = tc.isDelimitIdentifiers() || stringContainsSpace(tc.getCatalog())
|| stringContainsSpace(tc.getSchema()) || stringContainsSpace(tc.getTableName());
List<IntrospectedTable> answer = new ArrayList<IntrospectedTable>();
for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
ActualTableName atn = entry.getKey();
// we only use the returned catalog and schema if something was
// actually
// specified on the table configuration. If something was returned
// from the DB for these fields, but nothing was specified on the
// table
// configuration, then some sort of DB default is being returned
// and we don't want that in our SQL
FullyQualifiedTable table = new FullyQualifiedTable(stringHasValue(tc.getCatalog()) ? atn.getCatalog()
: null, stringHasValue(tc.getSchema()) ? atn.getSchema() : null, atn.getTableName(),
tc.getDomainObjectName(), tc.getAlias(),
isTrue(tc.getProperty(PropertyRegistry.TABLE_IGNORE_QUALIFIERS_AT_RUNTIME)),
tc.getProperty(PropertyRegistry.TABLE_RUNTIME_CATALOG),
tc.getProperty(PropertyRegistry.TABLE_RUNTIME_SCHEMA),
tc.getProperty(PropertyRegistry.TABLE_RUNTIME_TABLE_NAME), delimitIdentifiers, context);
IntrospectedTable introspectedTable = ObjectFactory.createIntrospectedTable(tc, table, context);
for (IntrospectedColumn introspectedColumn : entry.getValue()) {
introspectedTable.addColumn(introspectedColumn);
}
calculatePrimaryKey(table, introspectedTable);
answer.add(introspectedTable);
}
return answer;
}
代码示例来源:origin: lishuo9527/MybatisGenerator-UI
for (int i = 0; i < tableNames.length; i++) {
if (!tableNames[i].isEmpty() && !tableModels[i].isEmpty()) {
TableConfiguration tableConfiguration = new TableConfiguration(context);
tableConfiguration.setTableName(tableNames[i]);
tableConfiguration.setDomainObjectName(tableModels[i]);
tableConfiguration.setCountByExampleStatementEnabled(false);
tableConfiguration.setDeleteByExampleStatementEnabled(false);
tableConfiguration.setSelectByExampleStatementEnabled(false);
tableConfiguration.setUpdateByExampleStatementEnabled(false);
tableConfiguration.getProperties().setProperty("useActualColumnNames", "false");
tableConfigurations.add(tableConfiguration);
代码示例来源:origin: cxjava/mybatis-generator-core
Pattern pattern = null;
String replaceString = null;
if (tc.getColumnRenamingRule() != null) {
pattern = Pattern.compile(tc.getColumnRenamingRule().getSearchString());
replaceString = tc.getColumnRenamingRule().getReplaceString();
replaceString = replaceString == null ? "" : replaceString; //$NON-NLS-1$
if (isTrue(tc.getProperty(PropertyRegistry.TABLE_USE_ACTUAL_COLUMN_NAMES))) {
introspectedColumn.setJavaProperty(getValidPropertyName(calculatedColumnName));
} else if (isTrue(tc.getProperty(PropertyRegistry.TABLE_USE_COMPOUND_PROPERTY_NAMES))) {
sb.setLength(0);
sb.append(calculatedColumnName);
if (tc.isColumnIgnored(introspectedColumn.getActualColumnName())) {
warn = false;
ColumnOverride co = tc.getColumnOverride(introspectedColumn.getActualColumnName());
if (co != null) {
if (stringHasValue(co.getJavaType()) && stringHasValue(co.getJavaType())) {
if (tc.isAllColumnDelimitingEnabled()) {
introspectedColumn.setColumnNameDelimited(true);
代码示例来源:origin: roncoo/roncoo-mybatis-generator
boolean delimitIdentifiers = tc.isDelimitIdentifiers()
|| stringContainsSpace(tc.getCatalog())
|| stringContainsSpace(tc.getSchema())
|| stringContainsSpace(tc.getTableName());
localCatalog = tc.getCatalog();
localSchema = tc.getSchema();
localTableName = tc.getTableName();
} else if (databaseMetaData.storesLowerCaseIdentifiers()) {
localCatalog = tc.getCatalog() == null ? null : tc.getCatalog()
.toLowerCase();
localSchema = tc.getSchema() == null ? null : tc.getSchema()
.toLowerCase();
localTableName = tc.getTableName() == null ? null : tc
.getTableName().toLowerCase();
} else if (databaseMetaData.storesUpperCaseIdentifiers()) {
localCatalog = tc.getCatalog() == null ? null : tc.getCatalog()
.toUpperCase();
localSchema = tc.getSchema() == null ? null : tc.getSchema()
.toUpperCase();
localTableName = tc.getTableName() == null ? null : tc
.getTableName().toUpperCase();
} else {
localCatalog = tc.getCatalog();
localSchema = tc.getSchema();
localTableName = tc.getTableName();
if (tc.isWildcardEscapingEnabled()) {
String escapeString = databaseMetaData.getSearchStringEscape();
代码示例来源:origin: MarkGao11520/acmen-helper
TableConfiguration tableConfiguration = new TableConfiguration(context);
tableConfiguration.setTableName(tableName);
if (StringUtils.isNotEmpty(modelName)){
tableConfiguration.setDomainObjectName(modelName);
tableConfiguration.setGeneratedKey(new GeneratedKey("id", "Mysql", true, null));
context.addTableConfiguration(tableConfiguration);
代码示例来源:origin: org.mybatis.generator/mybatis-generator-core
String tableName = composeFullyQualifiedTableName(tc.getCatalog(), tc
.getSchema(), tc.getTableName(), '.');
if (!tc.areAnyStatementsEnabled()) {
warnings.add(getString("Warning.0", tableName)); //$NON-NLS-1$
continue;
代码示例来源:origin: PowerShenli/MyDog
String domainName = entProp.getString("entityName");
TableConfiguration tableConfig = new TableConfiguration(context);
tableConfig.setTableName(DDLUtils.getTbName(domainName));
tableConfig.setDomainObjectName(domainName);
tableConfig.addIgnoredColumn(ignoredColumn);
});
tableConfig.addColumnOverride(col);
});
context.addTableConfiguration(tableConfig);
代码示例来源:origin: roncoo/roncoo-mybatis-generator
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()));
}
}
}
代码示例来源:origin: beihaifeiwu/dolphin
public String fetchTypeName(IntrospectedColumn introspectedColumn){
String columnName = introspectedColumn.getActualColumnName();
String catalog = introspectedColumn.getIntrospectedTable().getTableConfiguration().getCatalog();
String schema = introspectedColumn.getIntrospectedTable().getTableConfiguration().getSchema();
String table = introspectedColumn.getIntrospectedTable().getTableConfiguration().getTableName();
String dataType = null;
try {
ResultSet set = connection.getMetaData().getColumns(catalog, schema, table, columnName);
while(set.next()){
dataType = set.getString("TYPE_NAME");
}
} catch (SQLException e) {
e.printStackTrace();
}
return dataType;
}
代码示例来源:origin: org.mybatis.generator/mybatis-generator-core
public GeneratedKey getGeneratedKey() {
return tableConfiguration.getGeneratedKey();
}
代码示例来源:origin: com.github.hongframework/hframe-webgenerator
public static void generator(String mybatisConfigFile, String companyCode, String programCode, String moduleCode) throws Exception {
List<TableConfiguration> tableConfigurations = MyBatisGeneratorUtil.getTableCfg(new File(mybatisConfigFile));
for (TableConfiguration tableConfiguration : tableConfigurations) {
Table table = new Table();
table.setTableName(tableConfiguration.getTableName());
table.setTableDesc(tableConfiguration.getProperty("chineseName"));
table.setParentId(tableConfiguration.getProperty("parentId"));
table.setDbId(tableConfiguration.getGeneratedKey().getColumn());
serviceGenerate(companyCode, programCode, moduleCode, table);
controllerGenerate(companyCode,programCode, moduleCode, table);
}
}
代码示例来源:origin: roncoo/roncoo-mybatis-generator
private void parseGeneratedKey(TableConfiguration tc, Node node) {
Properties attributes = parseAttributes(node);
String column = attributes.getProperty("column"); //$NON-NLS-1$
boolean identity = isTrue(attributes
.getProperty("identity")); //$NON-NLS-1$
String sqlStatement = attributes.getProperty("sqlStatement"); //$NON-NLS-1$
String type = attributes.getProperty("type"); //$NON-NLS-1$
GeneratedKey gk = new GeneratedKey(column, sqlStatement, identity, type);
tc.setGeneratedKey(gk);
}
代码示例来源:origin: org.mybatis.generator/mybatis-generator-core
private void parseIgnoreColumn(TableConfiguration tc, Node node) {
Properties attributes = parseAttributes(node);
String column = attributes.getProperty("column"); //$NON-NLS-1$
String delimitedColumnName = attributes
.getProperty("delimitedColumnName"); //$NON-NLS-1$
IgnoredColumn ic = new IgnoredColumn(column);
if (stringHasValue(delimitedColumnName)) {
ic.setColumnNameDelimited(isTrue(delimitedColumnName));
}
tc.addIgnoredColumn(ic);
}
代码示例来源:origin: cxjava/mybatis-generator-core
tc.addColumnOverride(co);
代码示例来源:origin: com.github.hongframework/hframe-webgenerator
public static void generator() throws Exception {
List<TableConfiguration> tableConfigurations = MyBatisGeneratorUtil.getTableCfg();
for (TableConfiguration tableConfiguration : tableConfigurations) {
Table table = new Table();
table.setTableName(tableConfiguration.getTableName());
table.setTableDesc(tableConfiguration.getProperty("chineseName"));
table.setParentId(tableConfiguration.getProperty("parentId"));
serviceGenerate("", "hframe", "hframe", table);
controllerGenerate("", "hframe", "hframe", table);
}
}
代码示例来源:origin: dcendents/mybatis-generator-plugins
/**
* Remove the id columns from the sql statement. Useful when the generated update statement is trying to update an
* id column.
*
* @param introspectedTable
* the table
* @param element
* the element
*/
void removeIdColumns(IntrospectedTable introspectedTable, XmlElement element) {
List<String> updates = new ArrayList<>();
String alias = introspectedTable.getTableConfiguration().getAlias();
if (alias == null) {
alias = "";
} else {
alias = alias + ".";
}
List<IntrospectedColumn> ids = introspectedTable.getPrimaryKeyColumns();
for (IntrospectedColumn column : ids) {
String typeHandler = column.getTypeHandler() != null ? String.format(",typeHandler=%s", column.getTypeHandler()) : "";
String update = String.format("%4$s%1$s = #{record.%2$s,jdbcType=%3$s%5$s},", column.getActualColumnName(),
column.getJavaProperty(), column.getJdbcTypeName(), alias, typeHandler);
log.debug("update: {}", update);
updates.add(update);
}
if (!updates.isEmpty()) {
removeIdColumns(updates, element, null, -1);
}
}
代码示例来源:origin: cxjava/mybatis-generator-core
private void parseTable(Context context, Node node) {
TableConfiguration tc = new TableConfiguration(context);
context.addTableConfiguration(tc);
tc.setCatalog(catalog);
tc.setSchema(schema);
tc.setTableName(tableName);
tc.setDomainObjectName(domainObjectName);
tc.setAlias(alias);
tc.setInsertStatementEnabled(isTrue(enableInsert));
tc.setSelectByPrimaryKeyStatementEnabled(isTrue(enableSelectByPrimaryKey));
tc.setSelectByExampleStatementEnabled(isTrue(enableSelectByExample));
tc.setUpdateByPrimaryKeyStatementEnabled(isTrue(enableUpdateByPrimaryKey));
tc.setDeleteByPrimaryKeyStatementEnabled(isTrue(enableDeleteByPrimaryKey));
tc.setDeleteByExampleStatementEnabled(isTrue(enableDeleteByExample));
tc.setCountByExampleStatementEnabled(isTrue(enableCountByExample));
tc.setUpdateByExampleStatementEnabled(isTrue(enableUpdateByExample));
内容来源于网络,如有侵权,请联系作者删除!