[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: 19/Feb/14  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
Environment:

Symfony 2.3.8-DEV


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

 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



 Comments   
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

Generated at Mon Dec 22 12:14:27 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.