Skip to content

API for pessimistic locks (SELECT … FOR UPDATE) #1041

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
crionuke opened this issue Sep 2, 2021 · 2 comments
Closed

API for pessimistic locks (SELECT … FOR UPDATE) #1041

crionuke opened this issue Sep 2, 2021 · 2 comments
Labels
type: enhancement A general enhancement

Comments

@crionuke
Copy link

crionuke commented Sep 2, 2021

Hi, there!
There is any plans to implement some locking api for spring r2dbc (may be with R2dbcEntityTemplate)
as it was in classic spring data jpa like this

@Lock(LockModeType.PESSIMISTIC_WRITE)
List<User> findByLastname(String lastname);

And of course, would be glad to see any examples of workaround to implement pessimistic locking used current version of spring-data-r2dbc

@christophstrobl christophstrobl transferred this issue from spring-projects/spring-data-r2dbc Sep 6, 2021
@christophstrobl christophstrobl changed the title Api for pessimistic locks with spring-data-r2dbc Api for pessimistic locks Sep 6, 2021
@christophstrobl christophstrobl added the type: enhancement A general enhancement label Sep 6, 2021
@mp911de mp911de changed the title Api for pessimistic locks API for pessimistic locks (SELECT … FOR UPDATE) Sep 7, 2021
DiegoKrupitza added a commit to DiegoKrupitza/spring-data-jdbc that referenced this issue Feb 4, 2022
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for HSQLDB `Select ... FOR UPDATE`.

Related tickets spring-projects#1041
schauder pushed a commit that referenced this issue Feb 9, 2022
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for HSQLDB `Select ... FOR UPDATE`.

See #1041
Original pull request #1158
schauder added a commit that referenced this issue Feb 9, 2022
Refactored the unit tests to include a negative case and to separate the different scenarios tested.

Removed the default LockMode from the Lock annotation.
I have the feeling that most users will assume an exclusive Lock when none is specified, but also don't want to request stronger locks than required.

Original pull request #1158
See #1041
schauder pushed a commit that referenced this issue Feb 15, 2022
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for HSQLDB `Select ... FOR UPDATE`.

See #1041
Original pull request #1158
schauder added a commit that referenced this issue Feb 15, 2022
Refactored the unit tests to include a negative case and to separate the different scenarios tested.

Removed the default LockMode from the Lock annotation.
I have the feeling that most users will assume an exclusive Lock when none is specified, but also don't want to request stronger locks than required.

Original pull request #1158
See #1041
@DiegoKrupitza
Copy link
Contributor

DiegoKrupitza commented Feb 15, 2022

My current draft only considers derived queries so far, since this does not require tinkering around with the (native) custom query.
I hope I can create the PR for R2DBC soon.

DiegoKrupitza added a commit to DiegoKrupitza/spring-data-r2dbc that referenced this issue Feb 15, 2022
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for H2 `Select ... FOR UPDATE`.

Closes spring-projects/spring-data-relational#1041
Related tickets spring-projects#643
schauder added a commit that referenced this issue Feb 22, 2022
This allows both Spring Data R2DBC and Spring Data JDBC to use the same annotation.

See /issues/1041, spring-projects/spring-data-r2dbc/pull/720, /pull/1158
schauder added a commit that referenced this issue Feb 22, 2022
This allows both Spring Data R2DBC and Spring Data JDBC to use the same annotation.

See /issues/1041, spring-projects/spring-data-r2dbc/pull/720, /pull/1158
schauder pushed a commit that referenced this issue Feb 22, 2022
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for H2 `Select ... FOR UPDATE`.

Closes #1041
See #643,
Original pull request /pull/1158
schauder added a commit that referenced this issue Feb 22, 2022
@schauder
Copy link
Contributor

Closed by #910c340

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.

4 participants