Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-681

PATCH: UnitOfWork#lock locks by column names instead of field names

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA2
    • Fix Version/s: 2.0-BETA3
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      On line 1700 of UnitOfWork#lock column names are used instead of field names, I think the line should read:

      array_combine($class->getIdentifierFieldNames(), $this->entityIdentifiers[$oid]),
      

      A related question: when I load an instance by relation, e.g. $author = $book->getAuthor(), I cannot specify a lock type at that point, so I have to call $em->lock($author, LockType::PESSIMISTIC_WRITE) afterwards, which results in two database queries for the same record. Is it possible to do this at once, without setting a transaction isolation level?

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

          Fixed the UoW issue. Thanks!

          As for the second issue, there is really only one way to skip the second database call:

          Use a Fetch Join DQL to get both book and author and apply the pessimistic lock to that DQL. (Locking both the book and author)

          All the other way already created the Author proxy object and you won't be able to specify a locking hint on those lazy loading select statements, requiring you to do the second locking call.

          Show
          Benjamin Eberlei added a comment - Fixed the UoW issue. Thanks! As for the second issue, there is really only one way to skip the second database call: Use a Fetch Join DQL to get both book and author and apply the pessimistic lock to that DQL. (Locking both the book and author) All the other way already created the Author proxy object and you won't be able to specify a locking hint on those lazy loading select statements, requiring you to do the second locking call.
          Hide
          Dennis Verspuij added a comment -

          Hi Benjamin, thanks for the quick answer, I already thought you'd answer that. Only funny thing is that in my SQL log it seems the select query for the lock is called before the select query for populating the $author values! May be because it delays populating the values before its first use? In the lock could actually be done at once. Any ideas?

          Show
          Dennis Verspuij added a comment - Hi Benjamin, thanks for the quick answer, I already thought you'd answer that. Only funny thing is that in my SQL log it seems the select query for the lock is called before the select query for populating the $author values! May be because it delays populating the values before its first use? In the lock could actually be done at once. Any ideas?
          Hide
          Benjamin Eberlei added a comment -

          Ah ok that is a very good optimization case, let me think about how and if this is easily implementable.

          I close this issue now and open up a new one

          Show
          Benjamin Eberlei added a comment - Ah ok that is a very good optimization case, let me think about how and if this is easily implementable. I close this issue now and open up a new one

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Dennis Verspuij
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: