3939import java .util .regex .Matcher ;
4040import java .util .regex .Pattern ;
4141import java .util .stream .Collectors ;
42+ import java .util .stream .Stream ;
4243
4344/**
4445 * 实体表接口,记录实体和表的关系
@@ -55,6 +56,18 @@ public class EntityTable extends EntityProps<EntityTable> {
5556 @ Getter
5657 @ Setter
5758 protected String table ;
59+ /**
60+ * catalog 名称,配置后,会在表名前面加上 catalog 名称,规则为:catalog.schema.tableName,支持全局 mybatis.provider.catalog 配置
61+ */
62+ @ Getter
63+ @ Setter
64+ protected String catalog ;
65+ /**
66+ * schema 名称,配置后,会在表名前面加上 schema 名称,规则为:catalog.schema.tableName,支持全局 mybatis.provider.schema 配置
67+ */
68+ @ Getter
69+ @ Setter
70+ protected String schema ;
5871 /**
5972 * 实体类和字段转表名和字段名方式
6073 */
@@ -77,45 +90,45 @@ public class EntityTable extends EntityProps<EntityTable> {
7790 */
7891 @ Getter
7992 @ Setter
80- protected boolean ready ;
93+ protected boolean ready ;
8194 /**
8295 * 使用指定的 <resultMap>
8396 */
8497 @ Getter
8598 @ Setter
86- protected String resultMap ;
99+ protected String resultMap ;
87100 /**
88101 * 自动根据字段生成 <resultMap>
89102 */
90103 @ Getter
91104 @ Setter
92- protected boolean autoResultMap ;
105+ protected boolean autoResultMap ;
93106 /**
94107 * 已初始化自动ResultMap
95108 */
96- protected List <ResultMap > resultMaps ;
109+ protected List <ResultMap > resultMaps ;
97110 /**
98111 * 排除指定父类的所有字段
99112 */
100113 @ Getter
101114 @ Setter
102- protected Class <?>[] excludeSuperClasses ;
115+ protected Class <?>[] excludeSuperClasses ;
103116 /**
104117 * 排除指定类型的字段
105118 */
106119 @ Getter
107120 @ Setter
108- protected Class <?>[] excludeFieldTypes ;
121+ protected Class <?>[] excludeFieldTypes ;
109122 /**
110123 * 排除指定字段名的字段
111124 */
112125 @ Getter
113126 @ Setter
114- protected String [] excludeFields ;
127+ protected String [] excludeFields ;
115128 /**
116129 * 已经初始化的配置
117130 */
118- protected Set <Configuration > initConfiguration = new HashSet <>();
131+ protected Set <Configuration > initConfiguration = new HashSet <>();
119132 //<editor-fold desc="基础方法,必须实现的方法">
120133
121134 protected EntityTable (Class <?> entityClass ) {
@@ -130,7 +143,9 @@ public static EntityTable of(Class<?> entityClass) {
130143 * 获取 SQL 语句中使用的表名
131144 */
132145 public String tableName () {
133- return table ();
146+ return Stream .of (catalog (), schema (), table ())
147+ .filter (s -> s != null && !s .isEmpty ())
148+ .collect (Collectors .joining ("." ));
134149 }
135150
136151 /**
@@ -564,16 +579,16 @@ public boolean equals(Object o) {
564579 if (this == o ) return true ;
565580 if (!(o instanceof EntityTable )) return false ;
566581 EntityTable entity = (EntityTable ) o ;
567- return table ().equals (entity .table ());
582+ return tableName ().equals (entity .tableName ());
568583 }
569584
570585 @ Override
571586 public int hashCode () {
572- return Objects .hash (table ());
587+ return Objects .hash (tableName ());
573588 }
574589
575590 @ Override
576591 public String toString () {
577- return table ();
592+ return tableName ();
578593 }
579594}
0 commit comments