Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-822

Query with detached Entity as parameter fails to execute

    Details

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

      Description

      When dealing with detached entities, e.g. with the QueryCache, you cannot use these entities as parameters for other Query.

      Example:

      Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      $em->detach($user);
      $query = $em->createQuery('SELECT a FROM Address a WHERE a.User = ?1');
      $query->setParameter(1, $user); // $user is detached
      

      As $user is detached, the EntityManager does not have its identifier, so Query::_doExecute fails. (There is a "//TODO: Check that $value is MANAGED?" line near the failing line).

        Activity

        Hide
        Nico Kaiser added a comment -

        This patch should fix Doctrine\ORM\Query to work with detached Entities.

        Show
        Nico Kaiser added a comment - This patch should fix Doctrine\ORM\Query to work with detached Entities.
        Hide
        Benjamin Eberlei added a comment -

        Did some changes to the patch, but overally its now committed!

        Show
        Benjamin Eberlei added a comment - Did some changes to the patch, but overally its now committed!

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Nico Kaiser
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: