28
28
* Implementation of {@link ReactiveSelectOperation}.
29
29
*
30
30
* @author Mark Paluch
31
+ * @author Mikhail Polivakha
31
32
* @since 1.1
32
33
*/
33
34
class ReactiveSelectOperationSupport implements ReactiveSelectOperation {
@@ -43,7 +44,7 @@ public <T> ReactiveSelect<T> select(Class<T> domainType) {
43
44
44
45
Assert .notNull (domainType , "DomainType must not be null" );
45
46
46
- return new ReactiveSelectSupport <>(this .template , domainType , domainType , Query .empty (), null );
47
+ return new ReactiveSelectSupport <>(this .template , domainType , domainType , Query .empty (), null , null );
47
48
}
48
49
49
50
static class ReactiveSelectSupport <T > implements ReactiveSelect <T > {
@@ -54,38 +55,49 @@ static class ReactiveSelectSupport<T> implements ReactiveSelect<T> {
54
55
private final Query query ;
55
56
private final @ Nullable SqlIdentifier tableName ;
56
57
58
+ private final @ Nullable Integer fetchSize ;
59
+
57
60
ReactiveSelectSupport (R2dbcEntityTemplate template , Class <?> domainType , Class <T > returnType , Query query ,
58
- @ Nullable SqlIdentifier tableName ) {
61
+ @ Nullable SqlIdentifier tableName , @ Nullable Integer fetchSize ) {
59
62
60
63
this .template = template ;
61
64
this .domainType = domainType ;
62
65
this .returnType = returnType ;
63
66
this .query = query ;
64
67
this .tableName = tableName ;
68
+ this .fetchSize = fetchSize ;
65
69
}
66
70
67
71
@ Override
68
72
public SelectWithProjection <T > from (SqlIdentifier tableName ) {
69
73
70
74
Assert .notNull (tableName , "Table name must not be null" );
71
75
72
- return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName );
76
+ return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName , fetchSize );
73
77
}
74
78
75
79
@ Override
76
80
public <R > SelectWithQuery <R > as (Class <R > returnType ) {
77
81
78
82
Assert .notNull (returnType , "ReturnType must not be null" );
79
83
80
- return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName );
84
+ return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName , fetchSize );
85
+ }
86
+
87
+ @ Override
88
+ public SelectWithQuery <T > withFetchSize (int fetchSize ) {
89
+
90
+ Assert .notNull (returnType , "FetchSize must not be null" );
91
+
92
+ return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName , fetchSize );
81
93
}
82
94
83
95
@ Override
84
96
public TerminatingSelect <T > matching (Query query ) {
85
97
86
98
Assert .notNull (query , "Query must not be null" );
87
99
88
- return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName );
100
+ return new ReactiveSelectSupport <>(template , domainType , returnType , query , tableName , fetchSize );
89
101
}
90
102
91
103
@ Override
@@ -100,17 +112,17 @@ public Mono<Boolean> exists() {
100
112
101
113
@ Override
102
114
public Mono <T > first () {
103
- return template .doSelect (query .limit (1 ), domainType , getTableName (), returnType , RowsFetchSpec ::first );
115
+ return template .doSelect (query .limit (1 ), domainType , getTableName (), returnType , RowsFetchSpec ::first , fetchSize );
104
116
}
105
117
106
118
@ Override
107
119
public Mono <T > one () {
108
- return template .doSelect (query .limit (2 ), domainType , getTableName (), returnType , RowsFetchSpec ::one );
120
+ return template .doSelect (query .limit (2 ), domainType , getTableName (), returnType , RowsFetchSpec ::one , fetchSize );
109
121
}
110
122
111
123
@ Override
112
124
public Flux <T > all () {
113
- return template .doSelect (query , domainType , getTableName (), returnType , RowsFetchSpec ::all );
125
+ return template .doSelect (query , domainType , getTableName (), returnType , RowsFetchSpec ::all , fetchSize );
114
126
}
115
127
116
128
private SqlIdentifier getTableName () {
0 commit comments