diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/relation/AbstractRelation.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/relation/AbstractRelation.java index 989a4345..f4c33d5f 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/relation/AbstractRelation.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/relation/AbstractRelation.java @@ -88,7 +88,7 @@ abstract class AbstractRelation { //以使用者注解配置为主 this.targetTableInfo = StringUtil.isBlank(targetTable) ? TableInfoFactory.ofEntityClass(relationFieldWrapper.getMappingType()) : TableInfoFactory.ofTableName(targetTable); - this.targetSchema = targetSchema; + this.targetSchema = targetTableInfo != null ? targetTableInfo.getSchema() : targetSchema; this.targetTable = targetTableInfo != null ? targetTableInfo.getTableName() : targetTable; //当指定了 valueField 的时候,一般是 String Integer 等基本数据类型