Browse Source

Adapt to API changes in Spring Data Common's PersistentPropertyPathAccessor.

Fixes #1477.
Related ticket: spring-projects/spring-data-commons#2813.
pull/1489/head
Oliver Drotbohm 3 years ago
parent
commit
d68605b6d8
No known key found for this signature in database
GPG Key ID: C25FBFA0DA493A1D
  1. 5
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java
  2. 2
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java
  3. 7
      spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java
  4. 3
      spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/RelationalConverter.java
  5. 10
      spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java
  6. 2
      spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/PersistentPropertyPathExtension.java

5
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateChangeExecutionContext.java

@ -27,8 +27,8 @@ import org.springframework.data.jdbc.core.convert.InsertSubject; @@ -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 { @@ -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);

2
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java

@ -754,7 +754,7 @@ public class QueryMapper { @@ -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();

7
spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java

@ -32,7 +32,7 @@ import org.springframework.data.convert.CustomConversions.StoreConversions; @@ -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 { @@ -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);
}

3
spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/RelationalConverter.java

@ -21,6 +21,7 @@ import org.springframework.core.convert.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 { @@ -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}.

10
spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/WritingContext.java

@ -230,9 +230,9 @@ class WritingContext<T> { @@ -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> { @@ -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> { @@ -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,

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

@ -83,7 +83,7 @@ public class PersistentPropertyPathExtension { @@ -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());
}
/**

Loading…
Cancel
Save