Polishing.
Move off deprecated getRequiredLeafProperty() method in other places. See #1489
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<RelationalPersistentProperty> 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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -552,7 +552,7 @@ public interface DbAction<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
default Class<T> getEntityType() {
|
||||
return (Class<T>) getPropertyPath().getRequiredLeafProperty().getActualType();
|
||||
return (Class<T>) getPropertyPath().getLeafProperty().getActualType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ final class PathNode {
|
||||
*/
|
||||
Object getActualValue() {
|
||||
|
||||
return getPath().getRequiredLeafProperty().isQualified() //
|
||||
return getPath().getLeafProperty().isQualified() //
|
||||
? ((Pair<?,?>) getValue()).getSecond() //
|
||||
: getValue();
|
||||
}
|
||||
|
||||
@@ -123,14 +123,14 @@ class WritingContext<T> {
|
||||
private List<? extends DbAction<?>> insertAll(PersistentPropertyPath<RelationalPersistentProperty> path) {
|
||||
|
||||
RelationalPersistentEntity<?> persistentEntity = context
|
||||
.getRequiredPersistentEntity(path.getRequiredLeafProperty());
|
||||
.getRequiredPersistentEntity(path.getLeafProperty());
|
||||
List<DbAction.Insert<Object>> inserts = new ArrayList<>();
|
||||
from(path).forEach(node -> {
|
||||
|
||||
DbAction.WithEntity<?> parentAction = getAction(node.getParent());
|
||||
Map<PersistentPropertyPath<RelationalPersistentProperty>, Object> qualifiers = new HashMap<>();
|
||||
Object instance;
|
||||
if (node.getPath().getRequiredLeafProperty().isQualified()) {
|
||||
if (node.getPath().getLeafProperty().isQualified()) {
|
||||
|
||||
Pair<Object, Object> value = (Pair) node.getValue();
|
||||
qualifiers.put(node.getPath(), value.getFirst());
|
||||
@@ -213,8 +213,8 @@ class WritingContext<T> {
|
||||
// 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<T> {
|
||||
}
|
||||
|
||||
List<PathNode> 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<T> {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user