Skip to content

Custom Converters to support Collections #2548

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

Open
tcarlson25 opened this issue Jul 26, 2021 · 1 comment
Open

Custom Converters to support Collections #2548

tcarlson25 opened this issue Jul 26, 2021 · 1 comment
Assignees
Labels
for: team-attention An issue we need to discuss as a team to make progress in: documentation type: documentation A documentation update

Comments

@tcarlson25
Copy link

tcarlson25 commented Jul 26, 2021

If I have a List<Person> as a type, it would be great for the reading/writing converters to work with that type as well, or any Collection for that matter. The original discussion/comment about this issue can be found at issue #1006.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 26, 2021
@mp911de
Copy link
Member

mp911de commented Jul 27, 2021

Spring Data consistently retains property multiplicity meaning that collections, maps, and singular properties are converted element-wise by considering their actual type. For example, a collection of S (source) results in a collection of T (target). Part of the rationale is that when you read a particular value of a collection, you only have access to its class type but no knowledge of the component type. Arrays are different in that regard as their component type is always available.

For the time being, please wrap your List within a value type and register a converter for the to-be-created value type. Spring Data backs off during mapping and uses your converter instead.

@mp911de mp911de added the for: team-attention An issue we need to discuss as a team to make progress label Jul 27, 2021
@mp911de mp911de added in: documentation type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 14, 2022
@mp911de mp911de transferred this issue from spring-projects/spring-data-relational Feb 14, 2022
@mp911de mp911de self-assigned this Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-attention An issue we need to discuss as a team to make progress in: documentation type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants