本文整理汇总了Java中org.mybatis.generator.config.TableConfiguration.getDomainObjectName方法的典型用法代码示例。如果您正苦于以下问题:Java TableConfiguration.getDomainObjectName方法的具体用法?Java TableConfiguration.getDomainObjectName怎么用?Java TableConfiguration.getDomainObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.config.TableConfiguration
的用法示例。
在下文中一共展示了TableConfiguration.getDomainObjectName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean validate(List<String> warnings) {
// 如果配置了searchString 或者 replaceString,二者不允许单独存在
if ((getProperties().getProperty(PRO_SEARCH_STRING) == null && getProperties().getProperty(PRO_REPLACE_STRING) != null)
|| (getProperties().getProperty(PRO_SEARCH_STRING) != null && getProperties().getProperty(PRO_REPLACE_STRING) == null)) {
warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件的searchString、replaceString属性需配合使用,不能单独存在!");
return false;
}
// 如果table配置了domainObjectName或者mapperName就不要再启动该插件了
for (TableConfiguration tableConfiguration : context.getTableConfigurations()) {
if (tableConfiguration.getDomainObjectName() != null || tableConfiguration.getMapperName() != null) {
warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件请不要配合table的domainObjectName或者mapperName一起使用!");
return false;
}
}
return super.validate(warnings);
}
示例2: modelBaseRecordClassGenerated
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* 修改model
*/
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
Context context=introspectedTable.getContext();
for (OneToOne oto : introspectedTable.getOneToOnes()) {
String tableName = oto.getMappingTable();
TableConfiguration tc =getMapTc(tableName, context);
if (tc != null) {
String pakkage = getModelPackage(introspectedTable, context);
String domainName = tc.getDomainObjectName();
String type=pakkage+"."+domainName;
String fieldName = domainName.replaceFirst(new String(new char[] { domainName.charAt(0) }), new String(new char[] { domainName.charAt(0) }).toLowerCase());
org.mybatis.generator.api.dom.java.Field field = new org.mybatis.generator.api.dom.java.Field();
field.setName(fieldName);
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(type);
field.setType(fqjt);
field.setVisibility(JavaVisibility.PRIVATE);
topLevelClass.addImportedType(new FullyQualifiedJavaType(type));
topLevelClass.addField(field);
// get
Method getMethod = new Method();
getMethod.setVisibility(JavaVisibility.PUBLIC);
getMethod.setReturnType(fqjt);
getMethod.setName("get" + tc.getDomainObjectName());
getMethod.addBodyLine("return " + fieldName + ";");
topLevelClass.addMethod(getMethod);
// set
Method setMethod = new Method();
setMethod.setVisibility(JavaVisibility.PUBLIC);
setMethod.setName("set" + tc.getDomainObjectName());
setMethod.addParameter(new Parameter(new FullyQualifiedJavaType(type), fieldName));
setMethod.addBodyLine("this." + fieldName + "=" + fieldName + ";");
topLevelClass.addMethod(setMethod);
}
}
return super.modelBaseRecordClassGenerated(topLevelClass, introspectedTable);
}
示例3: modelBaseRecordClassGenerated
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* 修改model
*/
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
Context context=introspectedTable.getContext();
for (OneToMany otm : introspectedTable.getOneToManys()) {
String tableName = otm.getMappingTable();
TableConfiguration tc =getMapTc(tableName, context);
if (tc != null) {
String pakkage = getModelPackage(introspectedTable, context);
String domainName = tc.getDomainObjectName();
String type=pakkage+"."+domainName;
String fieldName = domainName.replaceFirst(new String(new char[] { domainName.charAt(0) }), new String(new char[] { domainName.charAt(0) }).toLowerCase())+"s";
org.mybatis.generator.api.dom.java.Field field = new org.mybatis.generator.api.dom.java.Field();
field.setName(fieldName);
FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType("java.util.List<"+type+">");
field.setType(fqjt);
field.setVisibility(JavaVisibility.PRIVATE);
topLevelClass.addImportedType(new FullyQualifiedJavaType(type));
topLevelClass.addImportedType(new FullyQualifiedJavaType("java.util.List"));
topLevelClass.addField(field);
// get
Method getMethod = new Method();
getMethod.setVisibility(JavaVisibility.PUBLIC);
getMethod.setReturnType(fqjt);
getMethod.setName("get" + tc.getDomainObjectName()+"s");
getMethod.addBodyLine("return " + fieldName + ";");
topLevelClass.addMethod(getMethod);
// set
Method setMethod = new Method();
setMethod.setVisibility(JavaVisibility.PUBLIC);
setMethod.setName("set" + tc.getDomainObjectName() + "s");
setMethod.addParameter(new Parameter(fqjt, fieldName));
setMethod.addBodyLine("this." + fieldName + "=" + fieldName + ";");
topLevelClass.addMethod(setMethod);
}
}
return super.modelBaseRecordClassGenerated(topLevelClass, introspectedTable);
}
示例4: validate
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean validate(List<String> warnings) {
// 如果table配置了domainObjectName或者mapperName就不要再启动该插件了
for (TableConfiguration tableConfiguration : context.getTableConfigurations()) {
if (tableConfiguration.getDomainObjectName() != null || tableConfiguration.getMapperName() != null) {
warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件请不要配合table的domainObjectName或者mapperName一起使用!");
return false;
}
}
return super.validate(warnings);
}
示例5: calculateIntrospectedTables
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
private IntrospectedTable calculateIntrospectedTables(TableConfiguration tc,
Map<ActualTableName, List<IntrospectedColumn>> columns) {
boolean delimitIdentifiers =
tc.isDelimitIdentifiers() || stringContainsSpace(tc.getCatalog())
|| stringContainsSpace(tc.getSchema()) || stringContainsSpace(tc.getTableName());
IntrospectedTable introspectedTable = null;
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 = ObjectFactory.createIntrospectedTable(tc, table, context);
for (IntrospectedColumn introspectedColumn : entry.getValue()) {
introspectedTable.addColumn(introspectedColumn);
}
calculatePrimaryKey(table, introspectedTable);
}
return introspectedTable;
}
示例6: calculateIntrospectedTables
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
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;
}
示例7: calculateIntrospectedTables
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* Calculate introspected tables.
*
* @param tc
* the tc
* @param columns
* the columns
* @return the list
*/
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);
//设置数据库表的备注信息
//start
try{
Statement stmt = this.databaseMetaData.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(new StringBuilder().append("SHOW TABLE STATUS LIKE '").append(atn.getTableName()).append("'").toString());
while (rs.next())//将数据库表得备注信息设置到remark字段
table.setRemark(rs.getString("COMMENT"));
closeResultSet(rs);
stmt.close();
}catch(Exception e){
e.printStackTrace();
}
//end
IntrospectedTable introspectedTable = ObjectFactory
.createIntrospectedTable(tc, table, context);
//TODO 自定义属性
introspectedTable.setOneToOnes(tc.getOneToOnes());
introspectedTable.setOneToManys(tc.getOneToManys());
for (IntrospectedColumn introspectedColumn : entry.getValue()) {
introspectedTable.addColumn(introspectedColumn);
}
calculatePrimaryKey(table, introspectedTable);
enhanceIntrospectedTable(introspectedTable);
answer.add(introspectedTable);
}
return answer;
}
示例8: calculateIntrospectedTables
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
/**
* Calculate introspected tables.
*
* @param tc
* the tc
* @param columns
* the columns
* @return the list
*/
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);
enhanceIntrospectedTable(introspectedTable);
answer.add(introspectedTable);
}
return answer;
}
示例9: calculateIntrospectedTables
import org.mybatis.generator.config.TableConfiguration; //导入方法依赖的package包/类
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;
}