[DDC-2808] Notice: Undefined index: joinColumns in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1527 with many-to-many relation and contains criteria Created: 21/Nov/13  Updated: 16/Mar/15  Resolved: 09/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Alex WARrior Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Symfony 2.3.8-DEV

Issue Links:
is duplicated by DDC-2988 Notice: Undefined index: joinColumns ... Awaiting Feedback


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();
            ->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']);

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

Comment by Benjamin Eberlei [ 09/Feb/14 ]

Contains is not supported in ORM 2.3, only stating with 2.5

Comment by Steve Müller [ 19/Feb/14 ]

Benjamin Eberlei I think this is not only related to 2.5. The original issue describe here refers to a PHP warning "Notice: Undefined index: joinColumns in Doctrine/ORM/Persisters/BasicEntityPersister.php line 1527" which has nothing todo with contains support IMO. See related issue: DDC-2988

Comment by Doctrine Bot [ 16/Mar/15 ]

A related Github Pull-Request [GH-1307] was labeled:

Generated at Wed Nov 25 13:38:27 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.