Skip to content

One-to-many relation: ResultSet contains ... multiple times #1073

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
zb226 opened this issue Oct 20, 2021 · 4 comments
Closed

One-to-many relation: ResultSet contains ... multiple times #1073

zb226 opened this issue Oct 20, 2021 · 4 comments
Labels
type: enhancement A general enhancement

Comments

@zb226
Copy link

zb226 commented Oct 20, 2021

Whenever an element class of an aggregate has its own field for the ID that is also used as keyColumn for the one-to-many relationship to its aggregate root, access to these elements will cause duplicated columns in the generated SQL and consequently warnings like:

ResultSet contains id multiple times

The problem is described in detail in this StackOverflow question.

Here is a small project repo to demonstrate the problem.

Desired behaviour: No warnings, the column accesses should probably be "squashed".

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 20, 2021
schauder added a commit that referenced this issue Oct 21, 2021
When the key column of a MappedCollection is also present in the contained entity that column got select twice.
We now check if the column already gets selected before adding it to the selection.

This only works properly if the column names derived for the entity property and the key column match exactly, which might require use of a `@Column` annotation depending on the used NamingStrategy.

Closes #1073
schauder added a commit that referenced this issue Oct 21, 2021
Code formatting.

See #1073
@schauder schauder added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 21, 2021
@henryKukk
Copy link

Hi,

Any news here?

Kr,
Henry

@codering
Copy link

codering commented Aug 5, 2022

How is it going now ?

@zb226
Copy link
Author

zb226 commented Aug 5, 2022

@codering It looks like the patch provided by @schauder wasn't satisfactory for the spring-data project lead :(

@schauder
Copy link
Contributor

schauder commented Aug 5, 2022

The project lead was quite happy with it (that's me). But Mark wasn't satisfied and I failed to convince him or improve the PR. I'll try to revisit it next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants