Skip to content

Don't retrieve generated keys on INSERT if primary key is defined. #939

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
wants to merge 1 commit into from

Conversation

rtlusty
Copy link
Contributor

@rtlusty rtlusty commented Mar 11, 2021

Closes #933

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 11, 2021
@rtlusty
Copy link
Contributor Author

rtlusty commented Mar 11, 2021

The change done on DefaultDataAccessStrategy seems to be quite huge in the Diff view, but basically there was just moved the existing code to an if block and the else branch covers the case, that primary key was already defined. The line, which prepares the INSERT statement is common for both branches of the condition. I found it more readable in this form.

Regarding the DefaultDataAccessStrategyUnitTests, I had to adapt verification of the all existing test cases, because all have used entity with user defined primary key value.

@schauder schauder self-requested a review March 12, 2021 10:28
@schauder schauder self-assigned this Mar 12, 2021
@schauder schauder added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 12, 2021
schauder pushed a commit that referenced this pull request Mar 12, 2021
schauder added a commit that referenced this pull request Mar 12, 2021
Extract method in order to make the code more readable.

Switch to #xxx syntax for issue numbers instead of gh-xxx.

Original pull request #939
@schauder
Copy link
Contributor

Thank you very much. That is polished and merged.

@schauder schauder closed this Mar 12, 2021
@schauder schauder added this to the 2.2 M5 (2021.0.0) milestone Mar 12, 2021
@rtlusty rtlusty deleted the issue/933 branch March 12, 2021 11:34
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 this pull request may close these issues.

Generated keys are retrieved even if the primary key value is defined
3 participants