DATACMNS-1296 - PersistentPropertyPathAccessor now properly handles intermediate nulls when setting values.
We now use a dedicated GetOptions instance for the lookup of the parent path in case SetOptions is defined to skip nulls so that the lookup does not fail if the parent path contains a null value.
This commit is contained in:
@@ -86,6 +86,20 @@ class SimplePersistentPropertyPathAccessorUnitTests {
|
||||
}).doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1296
|
||||
void skipsIntermediateNullsWhenSettingNestedValues() {
|
||||
|
||||
CustomerWrapperWrapper wrapper = new CustomerWrapperWrapper(null);
|
||||
|
||||
PersistentPropertyPathAccessor<CustomerWrapperWrapper> accessor = getAccessor(wrapper);
|
||||
PersistentPropertyPath<SamplePersistentProperty> path = context
|
||||
.getPersistentPropertyPath("wrapper.customer.firstname", CustomerWrapperWrapper.class);
|
||||
|
||||
assertThatCode(() -> {
|
||||
accessor.setProperty(path, "Dave", AccessOptions.defaultSetOptions().skipNulls());
|
||||
}).doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
private void assertFirstnamesSetFor(Customers customers, String path) {
|
||||
|
||||
PersistentPropertyPath<SamplePersistentProperty> propertyPath = context.getPersistentPropertyPath(path,
|
||||
@@ -124,4 +138,9 @@ class SimplePersistentPropertyPathAccessorUnitTests {
|
||||
static class CustomerWrapper {
|
||||
Customer customer;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class CustomerWrapperWrapper {
|
||||
CustomerWrapper wrapper;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user