mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
增加全局忽略 schema
This commit is contained in:
parent
b326a824b8
commit
1c9d3f6a96
@ -110,6 +110,11 @@ public class FlexGlobalConfig {
|
||||
*/
|
||||
private String versionColumn;
|
||||
|
||||
/**
|
||||
* 全局忽略 @Table 中配置的 schema
|
||||
*/
|
||||
private boolean ignoreSchema = false;
|
||||
|
||||
/**
|
||||
* 未匹配列处理器
|
||||
*/
|
||||
@ -329,6 +334,14 @@ public class FlexGlobalConfig {
|
||||
this.versionColumn = versionColumn;
|
||||
}
|
||||
|
||||
public boolean isIgnoreSchema() {
|
||||
return ignoreSchema;
|
||||
}
|
||||
|
||||
public void setIgnoreSchema(boolean ignoreSchema) {
|
||||
this.ignoreSchema = ignoreSchema;
|
||||
}
|
||||
|
||||
public UnMappedColumnHandler getUnMappedColumnHandler() {
|
||||
return unMappedColumnHandler;
|
||||
}
|
||||
|
||||
@ -235,6 +235,8 @@ public class TableInfoFactory {
|
||||
Reflector reflector = Reflectors.of(entityClass);
|
||||
tableInfo.setReflector(reflector);
|
||||
|
||||
FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig();
|
||||
|
||||
// 初始化表名
|
||||
Table table = entityClass.getAnnotation(Table.class);
|
||||
if (table == null) {
|
||||
@ -242,7 +244,9 @@ public class TableInfoFactory {
|
||||
if (vo != null) {
|
||||
TableInfo refTableInfo = ofEntityClass(vo.value());
|
||||
// 设置 VO 类对应的真实的表名
|
||||
tableInfo.setSchema(refTableInfo.getSchema());
|
||||
if (!config.isIgnoreSchema()) {
|
||||
tableInfo.setSchema(refTableInfo.getSchema());
|
||||
}
|
||||
tableInfo.setTableName(refTableInfo.getTableName());
|
||||
// 将 @Table 注解的属性复制到 VO 类当中
|
||||
if (vo.copyTableProps()) {
|
||||
@ -260,7 +264,9 @@ public class TableInfoFactory {
|
||||
tableInfo.setTableName(tableName);
|
||||
}
|
||||
} else {
|
||||
tableInfo.setSchema(table.schema());
|
||||
if (!config.isIgnoreSchema()) {
|
||||
tableInfo.setSchema(table.schema());
|
||||
}
|
||||
tableInfo.setTableName(table.value());
|
||||
tableInfo.setCamelToUnderline(table.camelToUnderline());
|
||||
tableInfo.setComment(table.comment());
|
||||
@ -317,8 +323,6 @@ public class TableInfoFactory {
|
||||
|
||||
List<Field> entityFields = getColumnFields(entityClass);
|
||||
|
||||
FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig();
|
||||
|
||||
TypeHandlerRegistry typeHandlerRegistry = null;
|
||||
if (config.getConfiguration() != null) {
|
||||
typeHandlerRegistry = config.getConfiguration().getTypeHandlerRegistry();
|
||||
|
||||
@ -823,6 +823,10 @@ public class MybatisFlexProperties {
|
||||
*/
|
||||
private String versionColumn;
|
||||
|
||||
/**
|
||||
* 全局忽略 @Table 中配置的 schema
|
||||
*/
|
||||
private boolean ignoreSchema = false;
|
||||
|
||||
public boolean isPrintBanner() {
|
||||
return printBanner;
|
||||
@ -896,6 +900,14 @@ public class MybatisFlexProperties {
|
||||
this.versionColumn = versionColumn;
|
||||
}
|
||||
|
||||
public boolean isIgnoreSchema() {
|
||||
return ignoreSchema;
|
||||
}
|
||||
|
||||
public void setIgnoreSchema(boolean ignoreSchema) {
|
||||
this.ignoreSchema = ignoreSchema;
|
||||
}
|
||||
|
||||
void applyTo(FlexGlobalConfig target) {
|
||||
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
mapper.from(isPrintBanner()).to(target::setPrintBanner);
|
||||
@ -907,6 +919,7 @@ public class MybatisFlexProperties {
|
||||
mapper.from(getLogicDeleteColumn()).to(target::setLogicDeleteColumn);
|
||||
mapper.from(getVersionColumn()).to(target::setVersionColumn);
|
||||
mapper.from(getTenantColumn()).to(target::setTenantColumn);
|
||||
mapper.from(isIgnoreSchema()).to(target::setIgnoreSchema);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user