-
Notifications
You must be signed in to change notification settings - Fork 358
Support AggregateReference in a Dto that contains only a single no-args constructor #1759
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
Support AggregateReference in a Dto that contains only a single no-args constructor #1759
Conversation
PS. I should mention for clarity, that the JdbcDtoInstantiatingConverter is a duplicate of the DtoInstantiatingConverter from Spring Relational with lines 92 - 102 added to support AggregateReference columns. |
Thanks for looking into this. Instead there seems to be some inconsistency in commons, namely the meaning of (persistent)property is not clear.
Note that the first two both contain The two variants of Instantiators start with the arguments of the constructor which the map to properties. This resolution seems to happen against I therefore think we should do one of the following: Either make I can't tell which would be the right thing to do. Therefore pinging @mp911de At the very least we should spend some time to explain the three properties of |
Thanks so much for your feedback. It definitely had me scratching my head when I was trying to work out the difference in purpose between the three properties. I have looked at the DtoInstantiatingConverter in spring-data-commons, making the following change, and it does indeed solve the issue. It does still pass all the tests in spring-data-commons and spring-data-relational, although I see that it is used in most spring-data projects so it may have other consequences.
Thanks for all your work on this project - it is inspiring. |
This has been fixed in spring-projects/spring-data-commons#3104. From this pull request we intend to keep the test. |
Thank you for your contribution. That's merged and backported now. |
This is a simple fix to populate AggregateReference columns for Class based Dtos which only have a No-args constructor. At present all other columns are correctly injected, it is just the AggregateReferences that are not transferred to the Dto.
I've added tests to my PR to prove the problem and the fix. In the following example, the 'productType' column for the ProductDTO will be null using the current main branch, while all other columns will be correctly populated.
Hope this is helpful. Please let me know your thoughts. Thanks!
Model
DTO
My Repository