DDC-2022: DiscriminatorMap mixing up namespaces #2549

Open
opened 2026-01-22 13:56:27 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 10, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user sem:

I have a superclass RuleLine that has NO namespace which has a discriminator map with 2 entities of which 1 has a namespace and one does not, doctrine however will always try to load the entity without namespace with the one that does saying something like :
Doctrine\ORM\Mapping\MappingException : Entity class 'Core\domain\meal\DietRuleLine' used in the discriminator map of class 'Core\domain\meal\MealRuleLine' does not exist.

Example:

<?php
/****
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"diet" = "\DietRuleLine", "meal" = "Core\domain\meal\MealRuleLine"})
 * @Table(name="ruleline")
 */
abstract class RuleLine extends \IdentifiableEntity {

MealRuleLine (WITH namespace):

<?php

namespace Core\domain\meal;

/****
 * @Entity
 * @Table(name="mealruleline")
 */
class MealRuleLine extends \RuleLine {

And DietRuleLine (NO NAMESPACE):

<?php

/****
 * @Entity
 * @Table(name="dietRuleLine")
 */
class DietRuleLine extends \RuleLine {

This always gives the following error :
{quote}
Doctrine\ORM\Mapping\MappingException : Entity class 'Core\domain\meal\DietRuleLine' used in the discriminator map of class 'Core\domain\meal\MealRuleLine' does not exist.
{quote}

Originally created by @doctrinebot on GitHub (Sep 10, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user sem: I have a superclass RuleLine that has NO namespace which has a discriminator map with 2 entities of which 1 has a namespace and one does not, doctrine however will always try to load the entity without namespace with the one that does saying something like : Doctrine\ORM\Mapping\MappingException : Entity class 'Core\domain\meal\DietRuleLine' used in the discriminator map of class 'Core\domain\meal\MealRuleLine' does not exist. Example: ``` <?php /**** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"diet" = "\DietRuleLine", "meal" = "Core\domain\meal\MealRuleLine"}) * @Table(name="ruleline") */ abstract class RuleLine extends \IdentifiableEntity { ``` MealRuleLine (WITH namespace): ``` <?php namespace Core\domain\meal; /**** * @Entity * @Table(name="mealruleline") */ class MealRuleLine extends \RuleLine { ``` And DietRuleLine (NO NAMESPACE): ``` <?php /**** * @Entity * @Table(name="dietRuleLine") */ class DietRuleLine extends \RuleLine { ``` This always gives the following error : {quote} Doctrine\ORM\Mapping\MappingException : Entity class 'Core\domain\meal\DietRuleLine' used in the discriminator map of class 'Core\domain\meal\MealRuleLine' does not exist. {quote}
admin added the Bug label 2026-01-22 13:56:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2549