Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user warrior:

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

@doctrinebot

Comment created by @beberlei:

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

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot

Comment created by @deeky666:

[~beberlei] 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

@doctrinebot

Comment created by @doctrinebot:

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

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.