feat: Add setLockMode, forUpdate, and forShare query methods#105
Merged
feat: Add setLockMode, forUpdate, and forShare query methods#105
Conversation
Add support for pessimistic locking in Yawn queries, allowing users to specify lock modes without breaking out to the underlying TypedCriteria. - Add YawnLockMode enum with NONE, PESSIMISTIC_READ, PESSIMISTIC_WRITE - Add lockMode field to YawnQuery - Add setLockMode(), forUpdate(), forShare() methods to BaseTypeSafeCriteriaBuilder - Add lock mode compilation in YawnTestQueryFactory - Add integration tests for the new lock mode API - Add documentation for lock modes in basic_queries.md
QuinnB73
commented
Jan 25, 2026
yawn-database-test/src/test/kotlin/com/faire/yawn/database/YawnLockModeTest.kt
Show resolved
Hide resolved
luanpotter
reviewed
Jan 25, 2026
yawn-database-test/src/test/kotlin/com/faire/yawn/database/YawnLockModeTest.kt
Outdated
Show resolved
Hide resolved
… it compiles to hibernate anyway
|
Looks like the following requested reviewers are unavailable:
|
luanpotter
reviewed
Jan 26, 2026
luanpotter
reviewed
Jan 26, 2026
Nava2
approved these changes
Jan 28, 2026
yawn-database-test/src/main/kotlin/com/faire/yawn/setup/hibernate/YawnTestCompiledQuery.kt
Show resolved
Hide resolved
| .maxResults(2) | ||
| .offset(1) | ||
| .list() | ||
| }.forUpdate().maxResults(2).offset(1).compile() as YawnTestCompiledQuery<Book> |
Contributor
There was a problem hiding this comment.
why did we get rid of the newlines? 😢
Collaborator
Author
There was a problem hiding this comment.
i didn't like it with the new lines haha, we can add them back
Member
There was a problem hiding this comment.
the as makes it weird with the newlines for me too, maybe we save the query to a var and do only the compile() as xxx in one line?
Member
There was a problem hiding this comment.
could even have a private test helper just on this file to do compile -> cast -> extract query -> cast (which is what we want)
Nava2
approved these changes
Jan 29, 2026
luanpotter
reviewed
Jan 29, 2026
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
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.
Adding support for pessimistic locking in Yawn queries, allowing users to specify lock modes without breaking out to the underlying TypedCriteria. To do this, I'm adding a lock mode abstraction to Yawn so that we're not coupled to Hibernate, and plumbing it through as needed. It'll still be up to people using Yawn to handle the lock modes in their query factory until we provide some reusable query factories.
Fixes #102