Repository navigation
Support optimistic locking for PostgreSQL upserts in JDBC - #2430
Open
yeomin4242 wants to merge 4 commits into
Open
yeomin4242 wants to merge 4 commits into
yeomin4242 wants to merge 4 commits into
Conversation
Prepare initial and incremented versions for JDBC upserts and compare the previous version when updating a conflicting PostgreSQL row. Report optimistic locking failures without proceeding with referenced entity changes. Add conditional conflict updates to the shared SQL model, retain unsupported-operation failures through strategy composition, and cover version initialization, conflicts, concurrency, immutable entities, and transactional aggregate rollback. Related to spring-projects#2277. Signed-off-by: YeongJae Min <whereismysejong@naver.com>
Reuse the aggregate template integration suite and PostgreSQL fixture for versioned upserts. Preserve the concurrency, rollback, version and strategy-composition cases across both loading modes, and remove the duplicate unversioned upsert case. Related to spring-projects#2277. Signed-off-by: YeongJae Min <whereismysejong@naver.com>
Add the blank line required before the multi-statement constructor body. Related to spring-projects#2277. Signed-off-by: YeongJae Min <whereismysejong@naver.com>
Drop the deleted-row reinsertion test covered by absent-row insertion and remove the duplicate future-version mismatch value. Retain version initialization, conflicts, concurrency, referenced-entity preservation and rollback coverage. Related to spring-projects#2277. Signed-off-by: YeongJae Min <whereismysejong@naver.com>
yeomin4242
marked this pull request as ready for review
November 14, 2026 12:19
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #2277.
Add optimistic locking support to Spring Data JDBC upserts for PostgreSQL.
For entities with
@Version, conflicting rows are updated only when the stored version matches the supplied version. Successful updates increment the version; mismatches raiseOptimisticLockingFailureException.New entities receive the usual initial version. If an entity already carries version
nbut no row exists, it is inserted with versionn + 1.This draft focuses on JDBC and PostgreSQL. Other built-in JDBC dialects reject versioned upserts with
UnsupportedOperationException. Unversioned upsert behavior is retained.