@@ -113,7 +113,7 @@ private static List<Expression> getSelectList(QueryMeta queryMeta, List<QueryMet
113
113
}
114
114
115
115
private InlineQuery createMainSelect (List <Expression > columns , AggregatePath rootPath , InlineQuery rootQuery ,
116
- List <QueryMeta > inlineQueries ) {
116
+ List <QueryMeta > inlineQueries ) {
117
117
118
118
SelectBuilder .SelectJoin select = StatementBuilder .select (columns ).from (rootQuery );
119
119
select = applyJoins (rootPath , inlineQueries , select );
@@ -127,7 +127,7 @@ private InlineQuery createMainSelect(List<Expression> columns, AggregatePath roo
127
127
*
128
128
* @param paths the paths to consider.
129
129
* @return a {@link Map} that contains all the inline queries indexed by the path to the entity that gets loaded by
130
- * the subquery.
130
+ * the subquery.
131
131
*/
132
132
private List <QueryMeta > createInlineQueries (PersistentPropertyPaths <?, RelationalPersistentProperty > paths ) {
133
133
@@ -149,7 +149,7 @@ private List<QueryMeta> createInlineQueries(PersistentPropertyPaths<?, Relationa
149
149
* that are not unique across tables and also the generated SQL doesn't contain quotes and funny column names, making
150
150
* them easier to understand and also potentially shorter.
151
151
*
152
- * @param basePath the path for which to create the inline query.
152
+ * @param basePath the path for which to create the inline query.
153
153
* @param condition a condition that is to be applied to the query. May be {@literal null}.
154
154
* @return an inline query for the given path.
155
155
*/
@@ -169,11 +169,8 @@ private QueryMeta createInlineQuery(AggregatePath basePath, @Nullable Condition
169
169
String rowCountAlias = aliases .getRowCountAlias (basePath );
170
170
Expression count = basePath .isRoot () ? new AliasedExpression (SQL .literalOf (1 ), rowCountAlias ) //
171
171
: AnalyticFunction .create ("count" , Expressions .just ("*" )) //
172
- .partitionBy ( //
173
- basePath .getTableInfo ().backReferenceColumnInfos ().toList ( //
174
- ci -> table .column (ci .name ()) //
175
- ) //
176
- ).as (rowCountAlias );
172
+ .partitionBy (basePath .getTableInfo ().backReferenceColumnInfos ().toColumnList (table ) //
173
+ ).as (rowCountAlias );
177
174
columns .add (count );
178
175
179
176
String backReferenceAlias = null ;
@@ -241,25 +238,25 @@ private String getIdentifierProperty(List<AggregatePath> paths) {
241
238
}
242
239
243
240
private static AnalyticFunction createRowNumberExpression (AggregatePath basePath , Table table ,
244
- String rowNumberAlias ) {
241
+ String rowNumberAlias ) {
245
242
AggregatePath .ColumnInfos reverseColumnInfos = basePath .getTableInfo ().backReferenceColumnInfos ();
246
243
return AnalyticFunction .create ("row_number" ) //
247
- .partitionBy (reverseColumnInfos .toList ( ci -> table . column ( ci . name ()) )) //
248
- .orderBy (reverseColumnInfos .toList ( ci -> table . column ( ci . name ()) )) //
244
+ .partitionBy (reverseColumnInfos .toColumnList ( table )) //
245
+ .orderBy (reverseColumnInfos .toColumnList ( table )) //
249
246
.as (rowNumberAlias );
250
247
}
251
248
252
249
/**
253
250
* Adds joins to a select.
254
251
*
255
- * @param rootPath the AggregatePath that gets selected by the select in question.
252
+ * @param rootPath the AggregatePath that gets selected by the select in question.
256
253
* @param inlineQueries all the inline queries to added as joins as returned by
257
- * {@link #createInlineQueries(PersistentPropertyPaths)}
258
- * @param select the select to modify.
254
+ * {@link #createInlineQueries(PersistentPropertyPaths)}
255
+ * @param select the select to modify.
259
256
* @return the original select but with added joins
260
257
*/
261
258
private SelectBuilder .SelectJoin applyJoins (AggregatePath rootPath , List <QueryMeta > inlineQueries ,
262
- SelectBuilder .SelectJoin select ) {
259
+ SelectBuilder .SelectJoin select ) {
263
260
264
261
RelationalPersistentProperty rootIdProperty = rootPath .getRequiredIdProperty ();
265
262
AggregatePath rootIdPath = rootPath .append (rootIdProperty );
@@ -286,12 +283,12 @@ private SelectBuilder.SelectJoin applyJoins(AggregatePath rootPath, List<QueryMe
286
283
* </ol>
287
284
*
288
285
* @param inlineQueries all in the inline queries for all the children, as returned by
289
- * {@link #createInlineQueries(PersistentPropertyPaths)}
290
- * @param select the select to which the where clause gets added.
286
+ * {@link #createInlineQueries(PersistentPropertyPaths)}
287
+ * @param select the select to which the where clause gets added.
291
288
* @return the modified select.
292
289
*/
293
290
private SelectBuilder .SelectOrdered applyWhereCondition (List <QueryMeta > inlineQueries ,
294
- SelectBuilder .SelectJoin select ) {
291
+ SelectBuilder .SelectJoin select ) {
295
292
296
293
SelectBuilder .SelectWhere selectWhere = (SelectBuilder .SelectWhere ) select ;
297
294
@@ -389,8 +386,8 @@ public AliasFactory getAliasFactory() {
389
386
* </table>
390
387
*
391
388
* @param rowNumberAlias the alias of the rownumber column of the subselect under consideration. This determines if
392
- * the other value is replaced by null or not.
393
- * @param alias the column potentially to be replaced by null
389
+ * the other value is replaced by null or not.
390
+ * @param alias the column potentially to be replaced by null
394
391
* @return a SQL expression.
395
392
*/
396
393
private static Expression filteredColumnExpression (String rowNumberAlias , String alias ) {
@@ -422,11 +419,12 @@ private static SimpleFunction greatest(List<Expression> expressions) {
422
419
}
423
420
424
421
record QueryMeta (AggregatePath basePath , InlineQuery inlineQuery , Collection <Expression > simpleColumns ,
425
- Collection <Expression > selectableExpressions , Expression id , Expression backReference , Expression key ,
426
- Expression rowNumber , Expression rowCount ) {
422
+ Collection <Expression > selectableExpressions , Expression id , Expression backReference ,
423
+ Expression key ,
424
+ Expression rowNumber , Expression rowCount ) {
427
425
428
426
static QueryMeta of (AggregatePath basePath , InlineQuery inlineQuery , Collection <Expression > simpleColumns ,
429
- Expression id , Expression backReference , Expression key , Expression rowNumber , Expression rowCount ) {
427
+ Expression id , Expression backReference , Expression key , Expression rowNumber , Expression rowCount ) {
430
428
431
429
List <Expression > selectableExpressions = new ArrayList <>(simpleColumns );
432
430
selectableExpressions .add (rowNumber );
0 commit comments