[DDC-1352] ErrorException: Undefined index in array Created: 30/Aug/11  Updated: 01/Sep/11  Resolved: 01/Sep/11

Status: Closed
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.1.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Søren Assignee: Guilherme Blanco
Resolution: Invalid Votes: 0
Labels: None

Windows 7, PHP 5.3.3


The following query:
"select c.id
from \\Domain
Cuisine c
left join c.nameTranslation t
left join t.translationValues v
left join v.language l
where v.value = :name
and l.id = :languageId"

Results in a PHP ErrorException in \Doctrine\ORM\Query\SqlWalker line 745:
$assoc = ( ! $relation['isOwningSide']) ? $targetClass->associationMappings[$relation['mappedBy']] : $relation;

When I step through the execution, the array entry: $relation['mappedBy'] gets the following value: "Domain\Translation" in the scope where the error occurs.
$targetClass->associationMappings has the following indices: "translation" and "language" and this leads to a "Undefined index" error and the execution breaks. It means that I cannot execute DQL queries, which is critical for the application to run.

<entity name="Domain\Cuisine" table="Cuisine" repository-class="Infrastructure\Persistence\Doctrine\Repository\CuisineRepository">
<id name="id" type="integer" column="Id">
<generator strategy="AUTO"/>
<many-to-one target-entity="Domain\Translation" field="nameTranslation">
<join-column name="NameTranslation_Id" referenced-column-name="Id"/>

<entity name="Domain\Translation" table="Translations">
<id name="id" type="integer" column="Id">
<generator strategy="AUTO" />
<one-to-many target-entity="Domain\TranslationValue" mapped-by="Domain\Translation" field="translationValues" orphan-removal="true">

<entity name="Domain\TranslationValue" table="TranslationValues">
<id name="id" type="integer" column="Id">
<generator strategy="AUTO" />

<field name="value" type="string" column="Value" />

<many-to-one field="translation" target-entity="Domain\Translation">
<join-column name="Translation_Id" nullable="false" referenced-column-name="Id" />

<many-to-one field="language" target-entity="Domain\Language">
<join-column name="Language_Id" nullable="false" referenced-column-name="Id" />

<entity name="Domain\Language" table="Languages" repository-class="\Infrastructure\Persistence\Doctrine\Repository\TranslationRepository">
<id name="id" type="integer" column="Id">
<generator strategy="AUTO" />
<field name="name" type="string" column="Name" />
<field name="shortIsoCode" type="string" column="ShortIsoCode"/>
<field name="longIsoCode" type="string" column="LongIsoCode"/>
<field name="isDefault" type="boolean" column="IsDefault" />

Comment by Guilherme Blanco [ 01/Sep/11 ]

Your mapping information is wrong.
The mappedBy value must reference the field name of the owning side, and not the class name.

Marking ticket as invalid.

Generated at Tue Dec 01 08:07:05 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.