Skip to content

Tighten the contract of PersistentPropertyPath regarding nullability #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
odrotbohm opened this issue Apr 4, 2023 · 0 comments
Closed
Assignees
Labels
in: mapping Mapping and conversion infrastructure

Comments

@odrotbohm
Copy link
Member

We should change the definition of PersistentPropertyPath to — in its public API — not allow empty instances anymore. Those violate the concept and bleed into the concept's API by having to make all methods nullable (returning null in exactly that "empty" case). An empty property path doesn't make any actual sense as you cannot reasonably answer the methods declared on the interface except by returning null, which then causes client code having to verify the returned values all the time.

This is now changed into only making PersistentPropertyPath.getParentPath() nullable and letting it return null for single segment paths. Adapted client code accordingly. ….getRequiredLeadProperty() is now deprecated in favour of ….getLeafProperty() not returning null anymore.

@odrotbohm odrotbohm added the in: mapping Mapping and conversion infrastructure label Apr 4, 2023
@odrotbohm odrotbohm added this to the 3.1 RC1 (2023.0.0) milestone Apr 4, 2023
@odrotbohm odrotbohm self-assigned this Apr 4, 2023
odrotbohm added a commit to spring-projects/spring-data-mongodb that referenced this issue Apr 4, 2023
…yPathAccessor.

In preparation of spring-projects/spring-data-commons#2813 we're moving off the implementation of PersistentPropertyPathAccessor and rather only implement PersistenPropertyAccessor.

Fixes #4354.
odrotbohm added a commit that referenced this issue Apr 4, 2023
odrotbohm added a commit that referenced this issue Apr 4, 2023
Nullable annotations and Objects.equals(…) and Objects.hash(…)/Objects.hashCode(…). Records for internal cache key.

Related issue: #2813.
odrotbohm added a commit that referenced this issue Apr 4, 2023
We should change the definition of `PersistentPropertyPath` to — in its public API — not allow empty instances anymore. Those violate the concept and bleed into the concept's API by having to make all methods nullable (returning null in exactly that "empty" case). An empty property path doesn't make any actual sense as you cannot reasonably answer the methods declared on the interface except by returning null, which then causes client code having to verify the returned values all the time.

This is now changed into only making `PersistentPropertyPath.getParentPath()` nullable and letting it return null for single segment paths. Adapted client code accordingly. `….getRequiredLeadProperty()` is now deprecated in favour of `….getLeafProperty()` not returning null anymore.

Fixes #2813.
odrotbohm added a commit that referenced this issue Apr 4, 2023
odrotbohm added a commit that referenced this issue Apr 4, 2023
Nullable annotations and Objects.equals(…) and Objects.hash(…)/Objects.hashCode(…). Records for internal cache key.

Related issue: #2813.
odrotbohm added a commit to spring-projects/spring-data-relational that referenced this issue Apr 4, 2023
odrotbohm added a commit to spring-projects/spring-data-cassandra that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping Mapping and conversion infrastructure
Projects
None yet
Development

No branches or pull requests

1 participant