Skip to content


DDC-2929: Pessimistic lock on Query does not update the entity with the DB values if it's already cached #3689

doctrinebot opened this Issue · 1 comment

2 participants


Jira issue originally created by user nail:

When asking for a pessimistic lock through a Query object, the entities already in the cache are not refreshed with the latest values from the database (unless you set the Query::HINT_REFRESH hint)


        try {
            $bar = $em->createQuery('SELECT b FROM Foo:Bar b WHERE = :id')
                        ->setParameter('id', 150)
            var_dump($bar->getAmount()); // Yields some positive value
            $bar = $em->createQuery('SELECT b FROM Foo:Bar b WHERE = :id')
                        ->setParameter('id', 150)
                        // ->setHint(\Doctrine\ORM\Query::HINT_REFRESH, true)
            var_dump($bar->getAmount()); // Yields 0

        } catch (\Exception $e) {

This is similar to DDC-1846

(Tested on 2.4.0 and 2.4.1)

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.