Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2808

Notice: Undefined index: joinColumns in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1527 with many-to-many relation and contains criteria

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.3.5
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony 2.3.8-DEV

      Description

      Field Annotation:

           /**
           * @ORM\ManyToMany(targetEntity="Asset")
           * @ORM\JoinTable(
           *      name="bookings_assets",
           *      joinColumns={@ORM\JoinColumn(name="booking_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)},
           *      inverseJoinColumns={@ORM\JoinColumn(name="asset_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)}
           * )
           */
      

      Criteria definition:

              $criteria = Criteria::create();
              $criteria
                  ->where($criteria::expr()->contains('assets', $asset))
              ;
      

      Throws error when apply this criteria to not-loaded collection (via persistent collection). Do not throws any errors when works with ArrayCollection.
      The error is

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

      It seems that annotationMapptings array doesn't contains joinColumns in root, it contains this key under joinTable key. May be fix would be (line 1527)

      return $this->_getSQLTableAlias($className) . '.' . (isset($this->_class->associationMappings[$field]['joinColumns']) ? $this->_class->associationMappings[$field]['joinColumns'][0]['name'] : $this->_class->associationMappings[$field]['joinTable']['joinColumns'][0]['name']);
      

      Update:
      After this fix I got the next error:

      Notice: Undefined index: CONTAINS in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1490
      

      Seems that you doesn't support contains method in this persister

        Issue Links

          Activity

          Alex WARrior created issue -
          Alex WARrior made changes -
          Field Original Value New Value
          Description Field Annotation:
          {code}
               /**
               * @ORM\ManyToMany(targetEntity="Asset")
               * @ORM\JoinTable(
               * name="bookings_assets",
               * joinColumns={@ORM\JoinColumn(name="booking_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)},
               * inverseJoinColumns={@ORM\JoinColumn(name="asset_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)}
               * )
               */
          {code}

          Criteria definition:
          {code}
                  $criteria = Criteria::create();
                  $criteria
                      ->where($criteria::expr()->contains('assets', $asset))
                  ;
          {code}

          Throws error when apply this criteria to not-loaded collection (via persistent collection). Do not throws any errors when works with ArrayCollection.
          The error is
          {code}
                  Notice: Undefined index: joinColumns in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1527
          {code}

          It seems that annotationMapptings array doesn't contains joinColumns in root, it contains this key under joinTable key. May be fix would be (line 1527)

          {code}
          return $this->_getSQLTableAlias($className) . '.' . (isset($this->_class->associationMappings[$field]['joinColumns']) ? $this->_class->associationMappings[$field]['joinColumns'][0]['name'] : $this->_class->associationMappings[$field]['jointTable']['joinColumns'][0]['name']);
          {code}
          Field Annotation:
          {code}
               /**
               * @ORM\ManyToMany(targetEntity="Asset")
               * @ORM\JoinTable(
               * name="bookings_assets",
               * joinColumns={@ORM\JoinColumn(name="booking_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)},
               * inverseJoinColumns={@ORM\JoinColumn(name="asset_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)}
               * )
               */
          {code}

          Criteria definition:
          {code}
                  $criteria = Criteria::create();
                  $criteria
                      ->where($criteria::expr()->contains('assets', $asset))
                  ;
          {code}

          Throws error when apply this criteria to not-loaded collection (via persistent collection). Do not throws any errors when works with ArrayCollection.
          The error is
          {code}
                  Notice: Undefined index: joinColumns in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1527
          {code}

          It seems that annotationMapptings array doesn't contains joinColumns in root, it contains this key under joinTable key. May be fix would be (line 1527)

          {code}
          return $this->_getSQLTableAlias($className) . '.' . (isset($this->_class->associationMappings[$field]['joinColumns']) ? $this->_class->associationMappings[$field]['joinColumns'][0]['name'] : $this->_class->associationMappings[$field]['joinTable']['joinColumns'][0]['name']);
          {code}

          Update:
          After this fix I got the next error:
          {code}
          Notice: Undefined index: CONTAINS in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1490
          {code}
          Seems that you doesn't support contains method in this persister
          Benjamin Eberlei made changes -
          Fix Version/s 2.x [ 10090 ]
          Fix Version/s 2.3.5 [ 10521 ]
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.x [ 10090 ]
          Resolution Invalid [ 6 ]
          Steve Müller made changes -
          Link This issue is duplicated by DDC-2988 [ DDC-2988 ]

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Alex WARrior
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: