Adapt to API changes in Spring Data Common's PersistentPropertyPathAccessor.
Fixes #1477. Related ticket: spring-projects/spring-data-commons#2813.
This commit is contained in:
@@ -27,8 +27,8 @@ import org.springframework.data.jdbc.core.convert.InsertSubject;
|
||||
import org.springframework.data.jdbc.core.convert.JdbcConverter;
|
||||
import org.springframework.data.jdbc.core.convert.JdbcIdentifierBuilder;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PersistentPropertyPath;
|
||||
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.relational.core.conversion.DbAction;
|
||||
import org.springframework.data.relational.core.conversion.DbActionExecutionResult;
|
||||
@@ -290,7 +290,8 @@ class JdbcAggregateChangeExecutionContext {
|
||||
|
||||
RelationalPersistentEntity<S> persistentEntity = (RelationalPersistentEntity<S>) context
|
||||
.getRequiredPersistentEntity(action.getEntityType());
|
||||
PersistentPropertyAccessor<S> propertyAccessor = converter.getPropertyAccessor(persistentEntity, originalEntity);
|
||||
PersistentPropertyPathAccessor<S> propertyAccessor = converter.getPropertyAccessor(persistentEntity,
|
||||
originalEntity);
|
||||
|
||||
if (IdValueSource.GENERATED.equals(action.getIdValueSource())) {
|
||||
propertyAccessor.setProperty(persistentEntity.getRequiredIdProperty(), generatedId);
|
||||
|
||||
@@ -754,7 +754,7 @@ public class QueryMapper {
|
||||
throw new IllegalStateException("Cannot obtain a single column name for embedded property");
|
||||
}
|
||||
|
||||
if (this.property != null && this.path != null) {
|
||||
if (this.property != null && this.path != null && this.path.getParentPath() != null) {
|
||||
|
||||
RelationalPersistentProperty owner = this.path.getParentPath().getLeafProperty();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.convert.CustomConversions.StoreConversions;
|
||||
import org.springframework.data.mapping.Parameter;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||
import org.springframework.data.mapping.model.EntityInstantiators;
|
||||
@@ -120,9 +120,10 @@ public class BasicRelationalConverter implements RelationalConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> PersistentPropertyAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance) {
|
||||
public <T> PersistentPropertyPathAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity,
|
||||
T instance) {
|
||||
|
||||
PersistentPropertyAccessor<T> accessor = persistentEntity.getPropertyAccessor(instance);
|
||||
PersistentPropertyPathAccessor<T> accessor = persistentEntity.getPropertyPathAccessor(instance);
|
||||
return new ConvertingPropertyAccessor<>(accessor, conversionService);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.mapping.Parameter;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mapping.model.EntityInstantiators;
|
||||
import org.springframework.data.mapping.model.ParameterValueProvider;
|
||||
@@ -72,7 +73,7 @@ public interface RelationalConverter {
|
||||
* @param instance the instance to operate on. Must not be {@code null}.
|
||||
* @return guaranteed to be not {@code null}.
|
||||
*/
|
||||
<T> PersistentPropertyAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance);
|
||||
<T> PersistentPropertyPathAccessor<T> getPropertyAccessor(PersistentEntity<T, ?> persistentEntity, T instance);
|
||||
|
||||
/**
|
||||
* Read a relational value into the desired {@link TypeInformation destination type}.
|
||||
|
||||
@@ -230,9 +230,9 @@ class WritingContext<T> {
|
||||
|
||||
PersistentPropertyPath<RelationalPersistentProperty> currentPath = path.getParentPath();
|
||||
|
||||
while (!currentPath.isEmpty()) {
|
||||
while (currentPath != null) {
|
||||
|
||||
if (!currentPath.getRequiredLeafProperty().isEmbedded()) {
|
||||
if (!currentPath.getLeafProperty().isEmbedded()) {
|
||||
return false;
|
||||
}
|
||||
currentPath = currentPath.getParentPath();
|
||||
@@ -242,9 +242,9 @@ class WritingContext<T> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getFromRootValue(PersistentPropertyPath<RelationalPersistentProperty> path) {
|
||||
private Object getFromRootValue(@Nullable PersistentPropertyPath<RelationalPersistentProperty> path) {
|
||||
|
||||
if (path.getLength() == 0) {
|
||||
if (path == null) {
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ class WritingContext<T> {
|
||||
}
|
||||
|
||||
return context.getRequiredPersistentEntity(parent.getClass()).getPropertyAccessor(parent)
|
||||
.getProperty(path.getRequiredLeafProperty());
|
||||
.getProperty(path.getLeafProperty());
|
||||
}
|
||||
|
||||
private List<PathNode> createNodes(PersistentPropertyPath<RelationalPersistentProperty> path,
|
||||
|
||||
@@ -83,7 +83,7 @@ public class PersistentPropertyPathExtension {
|
||||
|
||||
public static boolean isWritable(PersistentPropertyPath<? extends RelationalPersistentProperty> path) {
|
||||
|
||||
return path.isEmpty() || (path.getRequiredLeafProperty().isWritable() && isWritable(path.getParentPath()));
|
||||
return path == null || path.getLeafProperty().isWritable() && isWritable(path.getParentPath());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user