39
39
import org .mybatis .dynamic .sql .where .AbstractWhereDSL ;
40
40
import org .mybatis .dynamic .sql .where .WhereModel ;
41
41
42
- public class QueryExpressionDSL <R > implements Buildable <R > {
42
+ public class QueryExpressionDSL <R > implements CompletableQuery <R > {
43
43
44
44
private String connector ;
45
45
private SelectDSL <R > selectDSL ;
@@ -82,14 +82,17 @@ public static <R> FromGatherer<R> selectDistinct(SelectDSL<R> selectDSL, BasicCo
82
82
.build ();
83
83
}
84
84
85
+ @ Override
85
86
public QueryExpressionWhereBuilder where () {
86
87
return new QueryExpressionWhereBuilder ();
87
88
}
88
89
90
+ @ Override
89
91
public <T > QueryExpressionWhereBuilder where (BindableColumn <T > column , VisitableCondition <T > condition ) {
90
92
return new QueryExpressionWhereBuilder (column , condition );
91
93
}
92
94
95
+ @ Override
93
96
public <T > QueryExpressionWhereBuilder where (BindableColumn <T > column , VisitableCondition <T > condition ,
94
97
SqlCriterion <?>...subCriteria ) {
95
98
return new QueryExpressionWhereBuilder (column , condition , subCriteria );
@@ -141,12 +144,14 @@ public JoinSpecificationStarter fullJoin(SqlTable joinTable, String tableAlias)
141
144
return fullJoin (joinTable );
142
145
}
143
146
147
+ @ Override
144
148
public GroupByFinisher groupBy (BasicColumn ...columns ) {
145
149
groupByModel = GroupByModel .of (columns );
146
150
selectDSL .addQueryExpression (buildModel ());
147
151
return new GroupByFinisher ();
148
152
}
149
153
154
+ @ Override
150
155
public SelectDSL <R > orderBy (SortSpecification ...columns ) {
151
156
buildDelegateMethod = selectDSL ::build ;
152
157
selectDSL .addQueryExpression (buildModel ());
@@ -156,12 +161,12 @@ public SelectDSL<R> orderBy(SortSpecification...columns) {
156
161
157
162
public UnionBuilder union () {
158
163
selectDSL .addQueryExpression (buildModel ());
159
- return new UnionBuilder ("union" ); //$NON-NLS-1$
164
+ return new UnionBuilder ();
160
165
}
161
166
162
167
public UnionBuilder unionAll () {
163
168
selectDSL .addQueryExpression (buildModel ());
164
- return new UnionBuilder ( "union all" ); //$NON-NLS-1$
169
+ return new UnionAllBuilder ();
165
170
}
166
171
167
172
protected QueryExpressionModel buildModel () {
@@ -176,18 +181,21 @@ protected QueryExpressionModel buildModel() {
176
181
.build ();
177
182
}
178
183
184
+ @ Override
179
185
public SelectDSL <R >.LimitFinisher limit (long limit ) {
180
186
buildDelegateMethod = selectDSL ::build ;
181
187
selectDSL .addQueryExpression (buildModel ());
182
188
return selectDSL .limit (limit );
183
189
}
184
190
191
+ @ Override
185
192
public SelectDSL <R >.OffsetFirstFinisher offset (long offset ) {
186
193
buildDelegateMethod = selectDSL ::build ;
187
194
selectDSL .addQueryExpression (buildModel ());
188
195
return selectDSL .offset (offset );
189
196
}
190
197
198
+ @ Override
191
199
public SelectDSL <R >.FetchFirstFinisher fetchFirst (long fetchFirstRows ) {
192
200
buildDelegateMethod = selectDSL ::build ;
193
201
selectDSL .addQueryExpression (buildModel ());
@@ -283,13 +291,13 @@ private <T> QueryExpressionWhereBuilder(BindableColumn<T> column, VisitableCondi
283
291
public UnionBuilder union () {
284
292
whereModel = buildWhereModel ();
285
293
selectDSL .addQueryExpression (buildModel ());
286
- return new UnionBuilder ("union" ); //$NON-NLS-1$
294
+ return new UnionBuilder ();
287
295
}
288
296
289
297
public UnionBuilder unionAll () {
290
298
whereModel = buildWhereModel ();
291
299
selectDSL .addQueryExpression (buildModel ());
292
- return new UnionBuilder ( "union all" ); //$NON-NLS-1$
300
+ return new UnionAllBuilder ();
293
301
}
294
302
295
303
public SelectDSL <R > orderBy (SortSpecification ...columns ) {
@@ -364,7 +372,7 @@ public JoinSpecificationFinisher on(BasicColumn joinColumn, JoinCondition joinCo
364
372
}
365
373
}
366
374
367
- public class JoinSpecificationFinisher implements Buildable <R > {
375
+ public class JoinSpecificationFinisher implements CompletableQuery <R > {
368
376
private SqlTable joinTable ;
369
377
private List <JoinCriterion > joinCriteria = new ArrayList <>();
370
378
private JoinType joinType ;
@@ -420,17 +428,20 @@ private R internalbuild() {
420
428
selectDSL .addQueryExpression (buildModel ());
421
429
return selectDSL .build ();
422
430
}
423
-
431
+
432
+ @ Override
424
433
public QueryExpressionWhereBuilder where () {
425
434
joinModel = buildJoinModel ();
426
435
return new QueryExpressionWhereBuilder ();
427
436
}
428
437
438
+ @ Override
429
439
public <T > QueryExpressionWhereBuilder where (BindableColumn <T > column , VisitableCondition <T > condition ) {
430
440
joinModel = buildJoinModel ();
431
441
return new QueryExpressionWhereBuilder (column , condition );
432
442
}
433
443
444
+ @ Override
434
445
public <T > QueryExpressionWhereBuilder where (BindableColumn <T > column , VisitableCondition <T > condition ,
435
446
SqlCriterion <?>...subCriteria ) {
436
447
joinModel = buildJoinModel ();
@@ -486,33 +497,44 @@ public JoinSpecificationStarter fullJoin(SqlTable joinTable, String tableAlias)
486
497
return fullJoin (joinTable );
487
498
}
488
499
500
+ @ Override
501
+ public GroupByFinisher groupBy (BasicColumn ...columns ) {
502
+ joinModel = buildJoinModel ();
503
+ return QueryExpressionDSL .this .groupBy (columns );
504
+ }
505
+
506
+ public UnionBuilder union () {
507
+ joinModel = buildJoinModel ();
508
+ return QueryExpressionDSL .this .union ();
509
+ }
510
+
511
+ public UnionBuilder unionAll () {
512
+ joinModel = buildJoinModel ();
513
+ return QueryExpressionDSL .this .unionAll ();
514
+ }
515
+
516
+ @ Override
489
517
public SelectDSL <R > orderBy (SortSpecification ...columns ) {
490
- buildDelegateMethod = selectDSL ::build ;
491
518
joinModel = buildJoinModel ();
492
- selectDSL .addQueryExpression (buildModel ());
493
- selectDSL .setOrderByModel (OrderByModel .of (columns ));
494
- return selectDSL ;
519
+ return QueryExpressionDSL .this .orderBy (columns );
495
520
}
496
521
522
+ @ Override
497
523
public SelectDSL <R >.LimitFinisher limit (long limit ) {
498
- buildDelegateMethod = selectDSL ::build ;
499
524
joinModel = buildJoinModel ();
500
- selectDSL .addQueryExpression (buildModel ());
501
- return selectDSL .limit (limit );
525
+ return QueryExpressionDSL .this .limit (limit );
502
526
}
503
527
528
+ @ Override
504
529
public SelectDSL <R >.OffsetFirstFinisher offset (long offset ) {
505
- buildDelegateMethod = selectDSL ::build ;
506
530
joinModel = buildJoinModel ();
507
- selectDSL .addQueryExpression (buildModel ());
508
- return selectDSL .offset (offset );
531
+ return QueryExpressionDSL .this .offset (offset );
509
532
}
510
533
534
+ @ Override
511
535
public SelectDSL <R >.FetchFirstFinisher fetchFirst (long fetchFirstRows ) {
512
- buildDelegateMethod = selectDSL ::build ;
513
536
joinModel = buildJoinModel ();
514
- selectDSL .addQueryExpression (buildModel ());
515
- return selectDSL .fetchFirst (fetchFirstRows );
537
+ return QueryExpressionDSL .this .fetchFirst (fetchFirstRows );
516
538
}
517
539
}
518
540
@@ -536,6 +558,14 @@ private R internalBuild() {
536
558
return selectDSL .build ();
537
559
}
538
560
561
+ public UnionBuilder union () {
562
+ return new UnionBuilder ();
563
+ }
564
+
565
+ public UnionBuilder unionAll () {
566
+ return new UnionAllBuilder ();
567
+ }
568
+
539
569
public SelectDSL <R >.LimitFinisher limit (long limit ) {
540
570
buildDelegateMethod = selectDSL ::build ;
541
571
return selectDSL .limit (limit );
@@ -553,10 +583,10 @@ public SelectDSL<R>.FetchFirstFinisher fetchFirst(long fetchFirstRows) {
553
583
}
554
584
555
585
public class UnionBuilder {
556
- private String connector ;
586
+ protected String connector ;
557
587
558
- public UnionBuilder (String connector ) {
559
- this .connector = Objects . requireNonNull ( connector );
588
+ public UnionBuilder () {
589
+ this .connector = "union" ; //$NON-NLS-1$
560
590
}
561
591
562
592
public FromGatherer <R > select (BasicColumn ...selectList ) {
@@ -578,4 +608,10 @@ public FromGatherer<R> selectDistinct(BasicColumn...selectList) {
578
608
.build ();
579
609
}
580
610
}
611
+
612
+ public class UnionAllBuilder extends UnionBuilder {
613
+ public UnionAllBuilder () {
614
+ connector = "union all" ; //$NON-NLS-1$
615
+ }
616
+ }
581
617
}
0 commit comments