-
Notifications
You must be signed in to change notification settings - Fork 682
DATACMNS-1762 - Support JDK Optional as return type in projections #457
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
Conversation
This commit adds 3 unit tests for using a JDK Optional as return type in a projection. 2 of them are working with a minimal change to ProjectingMethodInterceptor although I wonder if the change is ok like that, or if the Optional creation should be delegated to the conversionService. 1 unit test is failing: if the Optional is typed to another projection, the Optional does not contain the projection, leading to a ClassCastException.
Thanks, Wim. We have similar functionality in the repository abstraction with We would need to move all functionality but Let me know if that makes sense to you. |
Not really unfortunately. The last sentence I understood I think:
But the first part is a bit over my head I am afraid. This is my first look at the Spring Data code ever. I was already glad I could write some unit tests that show what I would like to have supported :-) |
That’s exactly how it was meant to be. Feel free to reach out if you need further guidance, happy to help. There are a few methods in QueryExecutionConverters that report type multiplicity and paging-capabilities (I.e.whether a wrapper can represent a List). My suggestion there is to leave those methods untouched for now. We can sort out these during the merge. |
This commit moves the NullableWrapper from org.springframework.data.repository.util to org.springframework.data.util, while keeping the old one in place (deprecated) for backwards compatibility.
I have added a new commit on the branch for the |
Re-reading your initial comment and I think I get it now:
Is that correct? If so, how would I then use |
Yes, that sounds about right.
Lines 129 to 146 in eed7658
Since |
I had another look, but it seems to difficult for me to fully understand what needs to happen, sorry for that. |
No worries. Let me have a look tomorrow at the PR to see how we can continue here. |
I took a look at the current state. It seems to be easier to start from scratch as this pull request contains a good start but it requires a bit more work to bring it into a state where it should be. What do you think about closing this PR and following DATACMNS-1762 to review the changes afterwards? Being unfamiliar with code isn't something to worry about. |
Ok for me. I think the unit tests I have written might be useful, so feel free to use them in your own PR if you think the same. |
I created a new pull request #459, specifically this commit shows the integration with |
This commit adds 3 unit tests for using a JDK Optional as return
type in a projection. 2 of them are working with a minimal change
to ProjectingMethodInterceptor although I wonder if the change is
ok like that, or if the Optional creation should be delegated to
the conversionService.
1 unit test is failing: if the Optional is typed to another projection,
the Optional does not contain the projection, leading to a ClassCastException.
Could somebody give a tip where to best fix that Optional-with-projection fail?