File tree Expand file tree Collapse file tree 2 files changed +30
-7
lines changed
src/main/java/org/mybatis/dynamic/sql Expand file tree Collapse file tree 2 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,9 @@ public class TableAliasCalculatorWithParent implements TableAliasCalculator {
24
24
private final TableAliasCalculator parent ;
25
25
private final TableAliasCalculator child ;
26
26
27
- public TableAliasCalculatorWithParent (TableAliasCalculator parent , TableAliasCalculator child ) {
28
- this . parent = Objects .requireNonNull (parent );
29
- this . child = Objects .requireNonNull (child );
27
+ private TableAliasCalculatorWithParent (Builder builder ) {
28
+ parent = Objects .requireNonNull (builder . parent );
29
+ child = Objects .requireNonNull (builder . child );
30
30
}
31
31
32
32
@ Override
@@ -46,4 +46,23 @@ public Optional<String> aliasForTable(SqlTable table) {
46
46
}
47
47
return parent .aliasForTable (table );
48
48
}
49
+
50
+ public static class Builder {
51
+ private TableAliasCalculator parent ;
52
+ private TableAliasCalculator child ;
53
+
54
+ public Builder withParent (TableAliasCalculator parent ) {
55
+ this .parent = parent ;
56
+ return this ;
57
+ }
58
+
59
+ public Builder withChild (TableAliasCalculator child ) {
60
+ this .child = child ;
61
+ return this ;
62
+ }
63
+
64
+ public TableAliasCalculatorWithParent build () {
65
+ return new TableAliasCalculatorWithParent (this );
66
+ }
67
+ }
49
68
}
Original file line number Diff line number Diff line change @@ -59,9 +59,10 @@ private QueryExpressionRenderer(Builder builder) {
59
59
}
60
60
61
61
/**
62
- * This function calculates a table alias calculator to use in the current context. In general,
63
- * there are two possibilities: this could be a renderer for a regular select statement, or it
64
- * could be a renderer for a select statement in an "exists" condition.
62
+ * This function calculates a table alias calculator to use in the current context. There are several
63
+ * possibilities: this could be a renderer for a regular select statement, or it could be a renderer for a table
64
+ * expression in a join, or a column to sub query where condition, or it could be a renderer for a select
65
+ * statement in an "exists" condition.
65
66
*
66
67
* <p>In the case of "exists" conditions, we will have a parent table alias calculator. We want to give visibility
67
68
* to the aliases in the outer select statement to this renderer so columns in aliased tables can be used in exists
@@ -91,7 +92,10 @@ private TableAliasCalculator calculateTableAliasCalculator(QueryExpressionModel
91
92
if (parentTableAliasCalculator == null ) {
92
93
return baseTableAliasCalculator ;
93
94
} else {
94
- return new TableAliasCalculatorWithParent (parentTableAliasCalculator , baseTableAliasCalculator );
95
+ return new TableAliasCalculatorWithParent .Builder ()
96
+ .withParent (parentTableAliasCalculator )
97
+ .withChild (baseTableAliasCalculator )
98
+ .build ();
95
99
}
96
100
}
97
101
You can’t perform that action at this time.
0 commit comments