Skip to content

feat: Add setLockMode, forUpdate, and forShare query methods#105

Merged
QuinnB73 merged 9 commits intomainfrom
quinn.add-lock-mode-support
Jan 29, 2026
Merged

feat: Add setLockMode, forUpdate, and forShare query methods#105
QuinnB73 merged 9 commits intomainfrom
quinn.add-lock-mode-support

Conversation

@QuinnB73
Copy link
Collaborator

@QuinnB73 QuinnB73 commented Jan 25, 2026

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

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 QuinnB73 requested review from a team and luanpotter January 25, 2026 19:57
@QuinnB73 QuinnB73 requested review from Nava2 and luanpotter January 26, 2026 20:13
@faire-pr-bot-app
Copy link

Looks like the following requested reviewers are unavailable:

  • Nava2: ⛔ Out of office returning Jan 28th

Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@QuinnB73 QuinnB73 enabled auto-merge (squash) January 27, 2026 22:11
.maxResults(2)
.offset(1)
.list()
}.forUpdate().maxResults(2).offset(1).compile() as YawnTestCompiledQuery<Book>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we get rid of the newlines? 😢

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't like it with the new lines haha, we can add them back

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could even have a private test helper just on this file to do compile -> cast -> extract query -> cast (which is what we want)

@QuinnB73 QuinnB73 requested review from Nava2 and luanpotter January 29, 2026 02:01
Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Co-authored-by: Luan Nico <luanpotter27@gmail.com>
@QuinnB73 QuinnB73 disabled auto-merge January 29, 2026 15:45
@QuinnB73 QuinnB73 enabled auto-merge (squash) January 29, 2026 15:46
@QuinnB73 QuinnB73 merged commit 7475eb8 into main Jan 29, 2026
7 checks passed
@QuinnB73 QuinnB73 deleted the quinn.add-lock-mode-support branch January 29, 2026 15:48
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

Successfully merging this pull request may close these issues.

Support setLockMode

3 participants