mirror of
https://github.com/doctrine/orm.git
synced 2026-04-26 16:08:03 +02:00
DDC-178: Query Hint for LOCK mechanisms plus support in $em->find() #218
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 26, 2009).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user @beberlei:
In some scenarios it is necessary to explicitly lock rows for update in a select query. My idea would be to support it twofold:
And if the values are set, set the appropriate query hints.
Updated API specification
LockModes
Constraints
API spec
$query->setLockMode(LockMode::OPTIMISTIC)
Effects:
$query->setLockMode(LockMode::PESSIMISTIC_READ/WRITE)
Effects:
$em->find($entity, LockMode::OPTIMISTIC) (or findBy et al)
Effects:
$em->find($entity, LockMode::OPTIMISTIC, $version) (or findBy et al)
Effects:
$em->find($entity, LockMode::PESSIMISTIC_READ/WRITE)
Effects:
$em->refresh($entity, LockMode::OPTIMISTIC)
Effects:
$em->refresh($entity, LockMode::PESSIMISTIC_READ/WRITE)
Effects:
$em->lock($entity, LockMode::OPTIMISTIC)
Effects:
$em->lock($entity, LockMode::PESSIMISTIC_READ/WRITE)
Effects:
** Issue straight, minimal locking SQL (we probably must* include the version column in the select), platform-specific. Note: Probably get the SQL from the persisters to account for different inheritance mapping strategies. The last part of the SQL, the locking clause, is taken from the platforms.