Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2988

Notice: Undefined index: joinColumns in BasicEntityPersister.php

    Details

    • Type: Bug Bug
    • Status: Awaiting Feedback
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.3.5, 2.4.2
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      When trying to use findBy on a ManyToMany field i receive the error:

      Notice: Undefined index: joinColumns in lib/Doctrine/ORM/Persisters/BasicEntityPersister.php

      It seems to be caused internally by the code expecting 'joinColumns' to be directly on the association, however it is found under 'joinTable'.
      I have attached a patch that atleast fixes my case, hopefully it can be used to pin-point what the error is.

        Issue Links

          Activity

          Hide
          Dennis Væversted added a comment -
          Show
          Dennis Væversted added a comment - Might be related to this one: http://www.doctrine-project.org/jira/browse/DDC-2808
          Hide
          Litz Ouille added a comment -

          Doctrine ORM 2.4.2 Here.

          Here are my annotations
          https://gist.github.com/LitzOuille/3cf2e73e169c032147ea

          The thing I'm trying to do is
          $questionRepository->findBy(array('contacts' => $ids)); // $ids = array(1,2,3, ...)

          Show
          Litz Ouille added a comment - Doctrine ORM 2.4.2 Here. Here are my annotations https://gist.github.com/LitzOuille/3cf2e73e169c032147ea The thing I'm trying to do is $questionRepository->findBy(array('contacts' => $ids)); // $ids = array(1,2,3, ...)
          Hide
          Marco Pivetta added a comment -

          Calin Pristavu did you validate your mappings?

          Show
          Marco Pivetta added a comment - Calin Pristavu did you validate your mappings?
          Hide
          Calin Pristavu added a comment -

          I failed, sorry.
          The error came from the many-to-many condition in the entity.
          Sorry for generating confusion, comment deleted !

          The many-to-one works just fine !

          Show
          Calin Pristavu added a comment - I failed, sorry. The error came from the many-to-many condition in the entity. Sorry for generating confusion, comment deleted ! The many-to-one works just fine !
          Hide
          Litz Ouille added a comment -

          A little feedback? Is this a bug? Can it be fixed?
          Thanks

          Show
          Litz Ouille added a comment - A little feedback? Is this a bug? Can it be fixed? Thanks
          Hide
          Marco Pivetta added a comment -

          Litz Ouille that particular repository call cannot work. How are we supposed to find an entity from a list of associated IDs? It would have to be the exact match...

          Assuming that API would work as I envision it, it looks like a missing feature.

          Dennis Væversted in order to accept a patch, we first need a failing test case demonstrating the failing scenario.

          Show
          Marco Pivetta added a comment - Litz Ouille that particular repository call cannot work. How are we supposed to find an entity from a list of associated IDs? It would have to be the exact match... Assuming that API would work as I envision it, it looks like a missing feature. Dennis Væversted in order to accept a patch, we first need a failing test case demonstrating the failing scenario.
          Hide
          Litz Ouille added a comment - - edited

          EDIT: Ok my bad.

          I am using findBy(array('id', $arrayIds)) and it is working. I thought I was using on a ManyToOne relationship, but no.

          EDIT2: @ocramius In fact I would like to find all questions for which the contacts' list contains at least one id. Something like
          SELECT q.*
          FROM Question q, QuestionContact qc //qc = jointable
          WHERE q.id = qc.question_id
          AND qc.contact_id IN ($ids)

          EDIT3: Actually when I try to findBy('ManyToMany', $id), it does not work either. I think I will have to use a repository for every query using a ManyToMany relationship.

          EDIT4: Ok, so, as said in the original post, findBy does not work with many-to-many.
          Notice: Undefined index: joinColumns (BasicEntityPersister.php line 1666)
          Dump($this->class->associationMappings[$field]): https://gist.github.com/LitzOuille/51929fdc3eda5576ed31

          Show
          Litz Ouille added a comment - - edited EDIT: Ok my bad. I am using findBy(array('id', $arrayIds)) and it is working. I thought I was using on a ManyToOne relationship, but no. EDIT2: @ocramius In fact I would like to find all questions for which the contacts' list contains at least one id. Something like SELECT q.* FROM Question q, QuestionContact qc //qc = jointable WHERE q.id = qc.question_id AND qc.contact_id IN ($ids) EDIT3: Actually when I try to findBy('ManyToMany', $id), it does not work either. I think I will have to use a repository for every query using a ManyToMany relationship. EDIT4: Ok, so, as said in the original post, findBy does not work with many-to-many. Notice: Undefined index: joinColumns (BasicEntityPersister.php line 1666) Dump($this->class->associationMappings [$field] ): https://gist.github.com/LitzOuille/51929fdc3eda5576ed31
          Hide
          Xander ten Boden added a comment - - edited

          I've got the same issue, also running doctrine 2.4.2:

          multiple users can have multiple departments:

          /**
           * @ORM\ManyToMany(targetEntity="CartelAuthDepartment", inversedBy="users")
           * @ORM\JoinTable(name="cartel_auth_user_has_cartel_auth_department",
           *		joinColumns={@ORM\JoinColumn(name="cartel_auth_user_id", referencedColumnName="id")},
           *		inverseJoinColumns={@ORM\JoinColumn(name="cartel_auth_department_id", referencedColumnName="id")}
           * )
           */
          private $departments;
          
          /**
           * @ORM\ManyToMany(targetEntity="\Cartel\AuthBundle\Entity\CartelAuth\CartelAuthUser", mappedBy="departments")
           */
          private $users;
          

          Then I want to find all the users that are within the departments that the current user has:

          $aAuthUsers = $oEm->getRepository('CartelAuthBundle:CartelAuth\CartelAuthUser')->findByDepartments($aAuthDepartments);
          

          This results in this error:

          Notice: Undefined index: joinColumns in .../vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1665

          Show
          Xander ten Boden added a comment - - edited I've got the same issue, also running doctrine 2.4.2: multiple users can have multiple departments: /** * @ORM\ManyToMany(targetEntity= "CartelAuthDepartment" , inversedBy= "users" ) * @ORM\JoinTable(name= "cartel_auth_user_has_cartel_auth_department" , * joinColumns={@ORM\JoinColumn(name= "cartel_auth_user_id" , referencedColumnName= "id" )}, * inverseJoinColumns={@ORM\JoinColumn(name= "cartel_auth_department_id" , referencedColumnName= "id" )} * ) */ private $departments; /** * @ORM\ManyToMany(targetEntity= "\Cartel\AuthBundle\Entity\CartelAuth\CartelAuthUser" , mappedBy= "departments" ) */ private $users; Then I want to find all the users that are within the departments that the current user has: $aAuthUsers = $oEm->getRepository('CartelAuthBundle:CartelAuth\CartelAuthUser')->findByDepartments($aAuthDepartments); This results in this error: Notice: Undefined index: joinColumns in .../vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1665

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Dennis Væversted
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: