diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java index a29a61c2..254fc307 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java @@ -15,7 +15,16 @@ */ package org.springframework.data.jdbc.core; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.function.BiConsumer; import java.util.stream.Collectors; @@ -386,7 +395,7 @@ class JdbcAggregateChangeExecutionContext { private MultiValueAggregator getAggregatorFor(PersistentPropertyPath path) { - PersistentProperty property = path.getRequiredLeafProperty(); + PersistentProperty property = path.getLeafProperty(); for (MultiValueAggregator aggregator : aggregators) { if (aggregator.handles(property)) { return aggregator; diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java index 4b6b7845..24c94394 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java @@ -212,7 +212,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { Class ownerType = getOwnerTyp(propertyPath); String statement = namespace(ownerType) + ".delete-" + toDashPath(propertyPath); - Class leafType = propertyPath.getRequiredLeafProperty().getTypeInformation().getType(); + Class leafType = propertyPath.getLeafProperty().getTypeInformation().getType(); MyBatisContext parameter = new MyBatisContext(rootId, null, leafType, Collections.emptyMap()); sqlSession().delete(statement, parameter); @@ -234,7 +234,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { @Override public void deleteAll(PersistentPropertyPath propertyPath) { - Class leafType = propertyPath.getRequiredLeafProperty().getTypeInformation().getType(); + Class leafType = propertyPath.getLeafProperty().getTypeInformation().getType(); String statement = namespace(getOwnerTyp(propertyPath)) + ".deleteAll-" + toDashPath(propertyPath); MyBatisContext parameter = new MyBatisContext(null, null, leafType, Collections.emptyMap()); @@ -293,7 +293,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { String statementName = namespace(getOwnerTyp(path)) + ".findAllByPath-" + path.toDotPath(); return sqlSession().selectList(statementName, - new MyBatisContext(identifier, null, path.getRequiredLeafProperty().getType())); + new MyBatisContext(identifier, null, path.getLeafProperty().getType())); } @Override diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java index 4ed2e9f1..4f1a26e1 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategyUnitTests.java @@ -274,7 +274,7 @@ public class MyBatisDataAccessStrategyUnitTests { when(path.getBaseProperty()).thenReturn(property); when(property.getOwner().getType()).thenReturn((Class) String.class); - when(path.getRequiredLeafProperty()).thenReturn(property); + when(path.getLeafProperty()).thenReturn(property); when(property.getType()).thenReturn((Class) Number.class); when(path.toDotPath()).thenReturn("dot.path"); diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java index 5aabc740..d055e829 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java @@ -552,7 +552,7 @@ public interface DbAction { @SuppressWarnings("unchecked") @Override default Class getEntityType() { - return (Class) getPropertyPath().getRequiredLeafProperty().getActualType(); + return (Class) getPropertyPath().getLeafProperty().getActualType(); } } } diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/PathNode.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/PathNode.java index 1eddafb3..144fbec3 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/PathNode.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/PathNode.java @@ -57,7 +57,7 @@ final class PathNode { */ Object getActualValue() { - return getPath().getRequiredLeafProperty().isQualified() // + return getPath().getLeafProperty().isQualified() // ? ((Pair) getValue()).getSecond() // : getValue(); } diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java index c0f1b296..b0ea0c17 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java @@ -123,14 +123,14 @@ class WritingContext { private List> insertAll(PersistentPropertyPath path) { RelationalPersistentEntity persistentEntity = context - .getRequiredPersistentEntity(path.getRequiredLeafProperty()); + .getRequiredPersistentEntity(path.getLeafProperty()); List> inserts = new ArrayList<>(); from(path).forEach(node -> { DbAction.WithEntity parentAction = getAction(node.getParent()); Map, Object> qualifiers = new HashMap<>(); Object instance; - if (node.getPath().getRequiredLeafProperty().isQualified()) { + if (node.getPath().getLeafProperty().isQualified()) { Pair value = (Pair) node.getValue(); qualifiers.put(node.getPath(), value.getFirst()); @@ -213,8 +213,8 @@ class WritingContext { // todo: this should go into pathnode Object parentValue = parentNode.getActualValue(); - Object value = path.getRequiredLeafProperty().getOwner().getPropertyAccessor(parentValue) - .getProperty(path.getRequiredLeafProperty()); + Object value = path.getLeafProperty().getOwner().getPropertyAccessor(parentValue) + .getProperty(path.getLeafProperty()); nodes.addAll(createNodes(path, parentNode, value)); }); @@ -265,11 +265,11 @@ class WritingContext { } List nodes = new ArrayList<>(); - if (path.getRequiredLeafProperty().isEmbedded()) { + if (path.getLeafProperty().isEmbedded()) { nodes.add(new PathNode(path, parentNode, value)); - } else if (path.getRequiredLeafProperty().isQualified()) { + } else if (path.getLeafProperty().isQualified()) { - if (path.getRequiredLeafProperty().isMap()) { + if (path.getLeafProperty().isMap()) { ((Map) value).forEach((k, v) -> nodes.add(new PathNode(path, parentNode, Pair.of(k, v)))); } else { @@ -278,7 +278,7 @@ class WritingContext { nodes.add(new PathNode(path, parentNode, Pair.of(k, listValue.get(k)))); } } - } else if (path.getRequiredLeafProperty().isCollectionLike()) { // collection value + } else if (path.getLeafProperty().isCollectionLike()) { // collection value if (value.getClass().isArray()) { asList((Object[]) value).forEach(v -> nodes.add(new PathNode(path, parentNode, v))); } else {