Skip to content

Commit d528913

Browse files
committed
partially fixing formatting
1 parent b9d3db2 commit d528913

File tree

6 files changed

+83
-89
lines changed

6 files changed

+83
-89
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/JdbcDeleteQueryCreator.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616
package org.springframework.data.jdbc.repository.query;
1717

18+
import java.util.ArrayList;
19+
import java.util.List;
20+
1821
import org.springframework.data.domain.Sort;
1922
import org.springframework.data.jdbc.core.convert.JdbcConverter;
2023
import org.springframework.data.jdbc.core.convert.QueryMapper;
@@ -26,17 +29,9 @@
2629
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
2730
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
2831
import org.springframework.data.relational.core.query.Criteria;
29-
import org.springframework.data.relational.core.sql.Column;
30-
import org.springframework.data.relational.core.sql.Condition;
31-
import org.springframework.data.relational.core.sql.Conditions;
32-
import org.springframework.data.relational.core.sql.Delete;
32+
import org.springframework.data.relational.core.sql.*;
3333
import org.springframework.data.relational.core.sql.DeleteBuilder.DeleteWhere;
34-
import org.springframework.data.relational.core.sql.Expression;
35-
import org.springframework.data.relational.core.sql.Expressions;
36-
import org.springframework.data.relational.core.sql.Select;
3734
import org.springframework.data.relational.core.sql.SelectBuilder.SelectWhere;
38-
import org.springframework.data.relational.core.sql.StatementBuilder;
39-
import org.springframework.data.relational.core.sql.Table;
4035
import org.springframework.data.relational.core.sql.render.SqlRenderer;
4136
import org.springframework.data.relational.repository.query.RelationalEntityMetadata;
4237
import org.springframework.data.relational.repository.query.RelationalParameterAccessor;
@@ -46,9 +41,6 @@
4641
import org.springframework.lang.Nullable;
4742
import org.springframework.util.Assert;
4843

49-
import java.util.ArrayList;
50-
import java.util.List;
51-
5244
/**
5345
* Implementation of {@link RelationalQueryCreator} that creates {@link List} of deletion {@link ParametrizedQuery} from
5446
* a {@link PartTree}.
@@ -101,7 +93,7 @@ protected List<ParametrizedQuery> complete(@Nullable Criteria criteria, Sort sor
10193
: queryMapper.getMappedObject(parameterSource, criteria, table, entity);
10294

10395
List<Column> idColumns = context.getAggregatePath(entity).getTableInfo().idColumnInfos()
104-
.toColumnList(table);
96+
.toList(ci -> table.column(ci.name()));
10597

10698
// create select criteria query for subselect
10799
SelectWhere selectBuilder = StatementBuilder.select(idColumns).from(table);
@@ -143,17 +135,17 @@ private void deleteRelations(List<Delete> deleteChain, RelationalPersistentEntit
143135

144136
SqlContext sqlContext = new SqlContext();
145137

146-
// MariaDB prior to 11.6 does not support aliases for delete statements
138+
// MariaDB prior to 11.6 does not support aliases for delete statements
147139
Table table = sqlContext.getUnaliasedTable(aggregatePath);
148140

149141
List<Column> reverseColumns = aggregatePath.getTableInfo().backReferenceColumnInfos()
150-
.toColumnList(table);
142+
.toList(ci -> table.column(ci.name()));
151143
Expression expression = Expressions.of(reverseColumns);
152144

153145
Condition inCondition = Conditions.in(expression, parentSelect);
154146

155147
List<Column> parentIdColumns = aggregatePath.getIdDefiningParentPath().getTableInfo().idColumnInfos()
156-
.toColumnList(table);
148+
.toList(ci -> table.column(ci.name()));
157149

158150
Select select = StatementBuilder.select( //
159151
parentIdColumns //

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/JdbcQueryCreator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ Join getJoin(SqlContext sqlContext, AggregatePath path) {
326326
Table parentTable = sqlContext.getTable(idDefiningParentPath);
327327

328328
List<Column> reverseColumns = path.getTableInfo().backReferenceColumnInfos().toColumnList(currentTable);
329-
List<Column> idColumns = idDefiningParentPath.getTableInfo().idColumnInfos()
330-
.toColumnList(parentTable);
329+
List<Column> idColumns = idDefiningParentPath.getTableInfo().idColumnInfos().toColumnList(parentTable);
331330
return new Join( //
332331
currentTable, //
333332
reverseColumns, //

spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/AggregatePath.java

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
* Represents a path within an aggregate starting from the aggregate root. The path can be iterated from the leaf to its
4343
* root.
4444
* <p>
45-
* It implements {@link Comparable} so that collections of {@code AggregatePath} instances can be sorted in a consistent way.
45+
* It implements {@link Comparable} so that collections of {@code AggregatePath} instances can be sorted in a consistent
46+
* way.
4647
*
4748
* @author Jens Schauder
4849
* @author Mark Paluch
@@ -246,7 +247,7 @@ default Stream<AggregatePath> stream() {
246247
* Returns the longest ancestor path that has an {@link org.springframework.data.annotation.Id} property.
247248
*
248249
* @return A path that starts just as this path but is shorter. Guaranteed to be not {@literal null}. TODO: throws
249-
* NoSuchElementException: No value present for empty paths
250+
* NoSuchElementException: No value present for empty paths
250251
*/
251252
AggregatePath getIdDefiningParentPath();
252253

@@ -259,24 +260,26 @@ default Stream<AggregatePath> stream() {
259260
@Nullable
260261
AggregatePath getTail();
261262

262-
263263
/**
264-
* Subtract the {@literal basePath} from {@literal this} {@literal AggregatePath} by removing the {@literal basePath} from the beginning of {@literal this}.
264+
* Subtract the {@literal basePath} from {@literal this} {@literal AggregatePath} by removing the {@literal basePath}
265+
* from the beginning of {@literal this}.
265266
*
266267
* @param basePath the path to be removed.
267-
* @return an AggregatePath that ends like the original {@literal AggregatePath} but has {@literal basePath} removed from the beginning.
268+
* @return an AggregatePath that ends like the original {@literal AggregatePath} but has {@literal basePath} removed
269+
* from the beginning.
268270
*/
269271
@Nullable
270272
AggregatePath subtract(@Nullable AggregatePath basePath);
271273

272274
/**
273275
* Compares this {@code AggregatePath} to another {@code AggregatePath} based on their dot path notation.
274276
* <p>
275-
* This is used to get {@code AggregatePath} instances sorted in a consistent way. Since this order affects generated SQL this also affects query caches and similar.
277+
* This is used to get {@code AggregatePath} instances sorted in a consistent way. Since this order affects generated
278+
* SQL this also affects query caches and similar.
276279
*
277280
* @param other the {@code AggregatePath} to compare to. Must not be {@literal null}.
278-
* @return a negative integer, zero, or a positive integer as this object's path is less than,
279-
* equal to, or greater than the specified object's path.
281+
* @return a negative integer, zero, or a positive integer as this object's path is less than, equal to, or greater
282+
* than the specified object's path.
280283
*/
281284
@Override
282285
default int compareTo(@NonNull AggregatePath other) {
@@ -286,21 +289,21 @@ default int compareTo(@NonNull AggregatePath other) {
286289
/**
287290
* Information about a table underlying an entity.
288291
*
289-
* @param qualifiedTableName the fully qualified name of the table this path is tied to or of the longest ancestor path that is actually
290-
* tied to a table. Must not be {@literal null}.
291-
* @param tableAlias the alias used for the table on which this path is based. May be {@literal null}.
292-
* @param backReferenceColumnInfos information about the columns used to reference back to the owning entity. Must not be {@literal null}. Since 3.5.
293-
* @param qualifierColumnInfo the column used for the list index or map key of the leaf property of this path. May be {@literal null}.
294-
* @param qualifierColumnType the type of the qualifier column of the leaf property of this path or {@literal null} if this is not applicable. May be {@literal null}.
295-
* @param idColumnInfos the column name of the id column of the ancestor path that represents an actual table. Must not be {@literal null}.
292+
* @param qualifiedTableName the fully qualified name of the table this path is tied to or of the longest ancestor
293+
* path that is actually tied to a table. Must not be {@literal null}.
294+
* @param tableAlias the alias used for the table on which this path is based. May be {@literal null}.
295+
* @param backReferenceColumnInfos information about the columns used to reference back to the owning entity. Must not
296+
* be {@literal null}. Since 3.5.
297+
* @param qualifierColumnInfo the column used for the list index or map key of the leaf property of this path. May be
298+
* {@literal null}.
299+
* @param qualifierColumnType the type of the qualifier column of the leaf property of this path or {@literal null} if
300+
* this is not applicable. May be {@literal null}.
301+
* @param idColumnInfos the column name of the id column of the ancestor path that represents an actual table. Must
302+
* not be {@literal null}.
296303
*/
297-
record TableInfo(
298-
SqlIdentifier qualifiedTableName,
299-
@Nullable SqlIdentifier tableAlias,
300-
ColumnInfos backReferenceColumnInfos,
301-
@Nullable ColumnInfo qualifierColumnInfo,
302-
@Nullable Class<?> qualifierColumnType,
303-
ColumnInfos idColumnInfos) {
304+
record TableInfo(SqlIdentifier qualifiedTableName, @Nullable SqlIdentifier tableAlias,
305+
ColumnInfos backReferenceColumnInfos, @Nullable ColumnInfo qualifierColumnInfo,
306+
@Nullable Class<?> qualifierColumnType, ColumnInfos idColumnInfos) {
304307

305308
static TableInfo of(AggregatePath path) {
306309

@@ -329,13 +332,13 @@ static TableInfo of(AggregatePath path) {
329332

330333
ColumnInfos idColumnInfos = computeIdColumnInfos(tableOwner, leafEntity);
331334

332-
return new TableInfo(qualifiedTableName, tableAlias, backReferenceColumnInfos, qualifierColumnInfo, qualifierColumnType,
333-
idColumnInfos);
335+
return new TableInfo(qualifiedTableName, tableAlias, backReferenceColumnInfos, qualifierColumnInfo,
336+
qualifierColumnType, idColumnInfos);
334337

335338
}
336339

337340
private static ColumnInfos computeIdColumnInfos(AggregatePath tableOwner,
338-
RelationalPersistentEntity<?> leafEntity) {
341+
RelationalPersistentEntity<?> leafEntity) {
339342

340343
ColumnInfos idColumnInfos = ColumnInfos.empty(tableOwner);
341344
if (!leafEntity.hasIdProperty()) {
@@ -370,8 +373,7 @@ private static ColumnInfos computeBackReferenceColumnInfos(AggregatePath path) {
370373
AggregatePath idDefiningParentPath = tableOwner.getIdDefiningParentPath();
371374
RelationalPersistentProperty idProperty = idDefiningParentPath.getRequiredLeafEntity().getIdProperty();
372375

373-
AggregatePath basePath = idProperty != null && idProperty.isEntity()
374-
? idDefiningParentPath.append(idProperty)
376+
AggregatePath basePath = idProperty != null && idProperty.isEntity() ? idDefiningParentPath.append(idProperty)
375377
: idDefiningParentPath;
376378
ColumInfosBuilder ciBuilder = new ColumInfosBuilder(basePath);
377379

@@ -394,11 +396,9 @@ private static ColumnInfos computeBackReferenceColumnInfos(AggregatePath path) {
394396
SqlIdentifier alias = AggregatePathTableUtils.prefixWithTableAlias(path, reverseColumnName);
395397

396398
if (idProperty != null) {
397-
ciBuilder.add(idProperty, reverseColumnName,
398-
alias);
399+
ciBuilder.add(idProperty, reverseColumnName, alias);
399400
} else {
400-
ciBuilder.add(idDefiningParentPath, reverseColumnName,
401-
alias);
401+
ciBuilder.add(idDefiningParentPath, reverseColumnName, alias);
402402
}
403403
}
404404
return ciBuilder.build();
@@ -414,7 +414,8 @@ public ColumnInfos backReferenceColumnInfos() {
414414
*
415415
* @return guaranteed not to be {@literal null}.
416416
* @throws IllegalStateException if there is not exactly one back referencing column.
417-
* @deprecated since there might be more than one reverse column instead. Use {@link #backReferenceColumnInfos()} instead.
417+
* @deprecated since there might be more than one reverse column instead. Use {@link #backReferenceColumnInfos()}
418+
* instead.
418419
*/
419420
@Deprecated(forRemoval = true)
420421
public ColumnInfo reverseColumnInfo() {
@@ -425,10 +426,12 @@ public ColumnInfo reverseColumnInfo() {
425426
* The id columns of the underlying table.
426427
* <p>
427428
* These might be:
428-
* <ul><li>the columns representing the id of the entity in question.
429-
* </li><li> the columns representing the id of a parent entity, which _owns_ the table. Note that this case also covers the first case.
430-
* </li><li> or the backReferenceColumns.
431-
* </li></ul>
429+
* <ul>
430+
* <li>the columns representing the id of the entity in question.</li>
431+
* <li>the columns representing the id of a parent entity, which _owns_ the table. Note that this case also covers
432+
* the first case.</li>
433+
* <li>or the backReferenceColumns.</li>
434+
* </ul>
432435
*
433436
* @return ColumnInfos representing the effective id of this entity. Guaranteed not to be {@literal null}.
434437
*/
@@ -438,7 +441,7 @@ public ColumnInfos effectiveIdColumnInfos() {
438441
}
439442

440443
/**
441-
* @param name the name of the column used to represent this property in the database.
444+
* @param name the name of the column used to represent this property in the database.
442445
* @param alias the alias for the column used to represent this property in the database.
443446
* @since 3.2
444447
*/
@@ -451,7 +454,7 @@ record ColumnInfo(SqlIdentifier name, SqlIdentifier alias) {
451454
* @param path the path to the {@literal ColumnInfo} for.
452455
* @return the {@link ColumnInfo}.
453456
* @throws IllegalArgumentException if the path is {@link #isRoot()}, {@link #isEmbedded()} or
454-
* {@link #isMultiValued()}.
457+
* {@link #isMultiValued()}.
455458
*/
456459
static ColumnInfo of(AggregatePath path) {
457460

@@ -483,8 +486,8 @@ class ColumnInfos {
483486
/**
484487
* Creates a new ColumnInfos instances based on the arguments.
485488
*
486-
* @param basePath The path on which all other paths in the other argument are based on. For the typical case of a
487-
* composite id, this would be the path to the composite ids.
489+
* @param basePath The path on which all other paths in the other argument are based on. For the typical case of a
490+
* composite id, this would be the path to the composite ids.
488491
* @param columnInfos A map, mapping {@literal AggregatePath} instances to the respective {@literal ColumnInfo}
489492
*/
490493
ColumnInfos(AggregatePath basePath, Map<AggregatePath, ColumnInfo> columnInfos) {
@@ -542,7 +545,7 @@ public boolean isEmpty() {
542545
* Applies a function to all the {@link ColumnInfo} instances and returns the result in a list.
543546
*
544547
* @param mapper the function to be applied
545-
* @param <T> the type returned by {@literal mapper} and contained in the resulting {@literal List}
548+
* @param <T> the type returned by {@literal mapper} and contained in the resulting {@literal List}
546549
* @return the list of results from mapper.
547550
*/
548551
public <T> List<T> toList(Function<ColumnInfo, T> mapper) {
@@ -561,12 +564,12 @@ public List<Column> toColumnList(Table table) {
561564
* {@link BinaryOperator combiner} is called with the current state (or initial {@code identity}) and the
562565
* accumulated {@code T} state to combine both into a single return value.
563566
*
564-
* @param identity the identity (initial) value for the combiner function.
567+
* @param identity the identity (initial) value for the combiner function.
565568
* @param accumulator an associative, non-interfering (free of side effects), stateless function for incorporating
566-
* an additional element into a result.
567-
* @param combiner an associative, non-interfering, stateless function for combining two values, which must be
568-
* compatible with the {@code accumulator} function.
569-
* @param <T> type of the result.
569+
* an additional element into a result.
570+
* @param combiner an associative, non-interfering, stateless function for combining two values, which must be
571+
* compatible with the {@code accumulator} function.
572+
* @param <T> type of the result.
570573
* @return result of the function.
571574
* @since 3.5
572575
*/

0 commit comments

Comments
 (0)