Skip to content
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

Select for Update default implementation in AbstractSqlLikeQueryBuilder #1330

Closed
dzou opened this issue Feb 10, 2022 · 6 comments
Closed

Select for Update default implementation in AbstractSqlLikeQueryBuilder #1330

dzou opened this issue Feb 10, 2022 · 6 comments

Comments

@dzou
Copy link

dzou commented Feb 10, 2022

Feature description

We recently upgraded micronaut versions and hit an error that Select For Update was not supported by AbstractSqlLikeQueryBuilder:

Wondering if there could just be a default impl that appends a for update to a select query in the right place? If not, then wanted to know why it is unimplemented, and how we could take advantage of it in repository methods?

@dstepanov
Copy link
Contributor

The method is left for the actual implementation to be implemented, ordinary sql vs jpql.

What is your use case of implementing the builder?

@dzou
Copy link
Author

dzou commented Feb 11, 2022

Oh I get it. So we hit this error when using the JpaQueryBuilder:

For update not supported for current query builder: JpaQueryBuilder

So I think our real request is if appendForUpdate could be implemented for JpaQueryBuilder? Or at least understand the limitations better for why it was not implemented.

@dstepanov
Copy link
Contributor

Correct me if i’m wrong but I don’t think JPA / Hibernate supports FOR UPDATE in the query. That’s why I added the error. Did it work for you before?

@dzou
Copy link
Author

dzou commented Feb 14, 2022

Ahh I see. I think it was just a no-op before and wasn't doing anything then.

From what i'm reading, it looks like in JPA that one needs to set the locking strategy to use "for update"? Like this: https://mobiarch.wordpress.com/2013/08/01/doing-select-for-update-in-jpa/

Is this something possible to set in the query builder? Or if not, how would we be able to use select-for-update functionality?

@dstepanov
Copy link
Contributor

The best solution would be to introduce a new annotation that would have LockModeType and then set it in the Hibernate repository implementation.

@dzou
Copy link
Author

dzou commented Feb 15, 2022

Ok, thanks for the infos. Gonna close this.

@dzou dzou closed this as completed Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants