MappingException line 420 after v3.5.3 update #7567

Closed
opened 2026-01-22 15:53:32 +01:00 by admin · 19 comments
Owner

Originally created by @davidnectarestudio on GitHub (Oct 28, 2025).

Bug Report

Q A
Version 3.5.3

Summary

After v3.5.3 update I'm getting this error message:

Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCompany\AirCompanyAttachment' in a field or discriminator column mapping.

Current behavior

!!  In MappingException.php line 420:
!!                                                                                 
!!    Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCom  
!!    pany\AirCompanyAttachment' in a field or discriminator column mapping. 

After Symfony clear cache command.

Expected behavior

No exception thrown.

How to reproduce

namespace App\Main\Domain\Model\AirCompany;

use App\Main\Domain\Model\Attachment\AbstractAttachment;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

#[ORM\Entity(repositoryClass: AirCompanyAttachmentRepository::class)]
#[Vich\Uploadable]
class AirCompanyAttachment extends AbstractAttachment
{
    #[Vich\UploadableField(mapping: 'air_company_attachments', fileNameProperty: 'vichFileName', size: 'size', mimeType: 'mimeType', originalName: 'path', dimensions: 'vichFileDimensions')]
    protected ?File $vichFile = null;
}
namespace App\Main\Domain\Model\Attachment;

use App\Shared\Domain\Model\AbstractBase;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

#[ORM\Entity(repositoryClass: AbstractAttachmentRepository::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')]
#[ORM\DiscriminatorMap([
    'attachment' => Attachment::class,
    'air_company' => AirCompanyAttachment::class,
    'rate' => RateAttachment::class,
])]
#[ORM\Table(name: 'attachment')]
#[Vich\Uploadable]
abstract class AbstractAttachment extends AbstractBase
{
    #[ORM\Column(name: 'vich_file_name', type: Types::STRING, length: 255, nullable: true)]
    private ?string $vichFileName = null;
namespace App\Shared\Domain\Model;

use Doctrine\ORM\Mapping as ORM;

abstract class AbstractBase implements \Stringable
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: Types::INTEGER)]
    protected ?int $id = null;
Originally created by @davidnectarestudio on GitHub (Oct 28, 2025). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | ------ | Version | 3.5.3 #### Summary After `v3.5.3` update I'm getting this error message: `Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCompany\AirCompanyAttachment' in a field or discriminator column mapping.` #### Current behavior ```bash !! In MappingException.php line 420: !! !! Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCom !! pany\AirCompanyAttachment' in a field or discriminator column mapping. ``` After Symfony clear cache command. #### Expected behavior No exception thrown. #### How to reproduce ```php namespace App\Main\Domain\Model\AirCompany; use App\Main\Domain\Model\Attachment\AbstractAttachment; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; use Vich\UploaderBundle\Mapping\Annotation as Vich; #[ORM\Entity(repositoryClass: AirCompanyAttachmentRepository::class)] #[Vich\Uploadable] class AirCompanyAttachment extends AbstractAttachment { #[Vich\UploadableField(mapping: 'air_company_attachments', fileNameProperty: 'vichFileName', size: 'size', mimeType: 'mimeType', originalName: 'path', dimensions: 'vichFileDimensions')] protected ?File $vichFile = null; } ``` ```php namespace App\Main\Domain\Model\Attachment; use App\Shared\Domain\Model\AbstractBase; use Doctrine\ORM\Mapping as ORM; use Vich\UploaderBundle\Mapping\Annotation as Vich; #[ORM\Entity(repositoryClass: AbstractAttachmentRepository::class)] #[ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'type', type: 'string')] #[ORM\DiscriminatorMap([ 'attachment' => Attachment::class, 'air_company' => AirCompanyAttachment::class, 'rate' => RateAttachment::class, ])] #[ORM\Table(name: 'attachment')] #[Vich\Uploadable] abstract class AbstractAttachment extends AbstractBase { #[ORM\Column(name: 'vich_file_name', type: Types::STRING, length: 255, nullable: true)] private ?string $vichFileName = null; ``` ```php namespace App\Shared\Domain\Model; use Doctrine\ORM\Mapping as ORM; abstract class AbstractBase implements \Stringable { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] protected ?int $id = null; ```
admin closed this issue 2026-01-22 15:53:32 +01:00
Author
Owner

@davidnectarestudio commented on GitHub (Oct 28, 2025):

Full exception stack trace here:

Doctrine\ORM\Mapping\MappingException:
Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCompany\AirCompanyAttachment' in a field or discriminator column mapping.

  at /application/vendor/doctrine/orm/src/Mapping/MappingException.php:420
  at Doctrine\ORM\Mapping\MappingException::duplicateColumnName('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', 'id')
     (/application/vendor/doctrine/orm/src/Mapping/ClassMetadata.php:1232)
  at Doctrine\ORM\Mapping\ClassMetadata->validateAndCompleteFieldMapping(object(FieldMapping))
     (/application/vendor/doctrine/orm/src/Mapping/ClassMetadata.php:1936)
  at Doctrine\ORM\Mapping\ClassMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'scale' => null, 'length' => null, 'unique' => false, 'nullable' => false, 'index' => false, 'precision' => null, 'id' => true))
     (/application/vendor/doctrine/orm/src/Mapping/Driver/AttributeDriver.php:329)
  at Doctrine\ORM\Mapping\Driver\AttributeDriver->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata))
     (/application/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php:61)
  at Doctrine\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata))
     (/application/vendor/doctrine/doctrine-bundle/src/Mapping/MappingDriver.php:41)
  at Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata))
     (/application/vendor/doctrine/orm/src/Mapping/ClassMetadataFactory.php:167)
  at Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), object(ClassMetadata), true, array('App\\Main\\Domain\\Model\\Attachment\\AbstractAttachment'))
     (/application/vendor/doctrine/doctrine-bundle/src/Mapping/ClassMetadataFactory.php:20)
  at Doctrine\Bundle\DoctrineBundle\Mapping\ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), object(ClassMetadata), true, array('App\\Main\\Domain\\Model\\Attachment\\AbstractAttachment'))
     (/application/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:318)
  at Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment')
     (/application/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:187)
  at Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment')
     (/application/vendor/doctrine/orm/src/Tools/SchemaValidator.php:130)
  at Doctrine\ORM\Tools\SchemaValidator->validateClass(object(ClassMetadata))
     (/application/vendor/doctrine/doctrine-bundle/src/DataCollector/DoctrineDataCollector.php:108)
  at Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector->collect(object(Request), object(Response), object(MappingException))
     (/application/vendor/symfony/http-kernel/Profiler/Profiler.php:158)
  at Symfony\Component\HttpKernel\Profiler\Profiler->collect(object(Request), object(Response), object(MappingException))
     (/application/vendor/symfony/http-kernel/EventListener/ProfilerListener.php:102)
  at Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher))
     (/application/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher))
     (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:206)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.response', object(ResponseEvent))
     (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:56)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ResponseEvent), 'kernel.response')
     (/application/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:126)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ResponseEvent), 'kernel.response')
     (/application/vendor/symfony/http-kernel/HttpKernel.php:216)
  at Symfony\Component\HttpKernel\HttpKernel->filterResponse(object(Response), object(Request), 2)
     (/application/vendor/symfony/http-kernel/HttpKernel.php:204)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 2)
     (/application/vendor/symfony/http-kernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 2, false)
     (/application/vendor/symfony/http-kernel/EventListener/ErrorListener.php:99)
  at Symfony\Component\HttpKernel\EventListener\ErrorListener->onKernelException(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
     (/application/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115)
  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher))
     (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:206)
  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(ExceptionEvent))
     (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:56)
  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception')
     (/application/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:126)
  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception')
     (/application/vendor/symfony/http-kernel/HttpKernel.php:241)
  at Symfony\Component\HttpKernel\HttpKernel->handleThrowable(object(MappingException), object(Request), 1)
     (/application/vendor/symfony/http-kernel/HttpKernel.php:134)
  at Symfony\Component\HttpKernel\HttpKernel->terminateWithException(object(MappingException), object(Request))
     (/application/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:84)
  at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::{closure:Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure():78}(object(MappingException))
     (/application/vendor/symfony/error-handler/ErrorHandler.php:538)
  at Symfony\Component\ErrorHandler\ErrorHandler->handleException(object(MappingException))          
@davidnectarestudio commented on GitHub (Oct 28, 2025): Full exception stack trace here: ```bash Doctrine\ORM\Mapping\MappingException: Duplicate definition of column 'id' on entity 'App\Main\Domain\Model\AirCompany\AirCompanyAttachment' in a field or discriminator column mapping. at /application/vendor/doctrine/orm/src/Mapping/MappingException.php:420 at Doctrine\ORM\Mapping\MappingException::duplicateColumnName('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', 'id') (/application/vendor/doctrine/orm/src/Mapping/ClassMetadata.php:1232) at Doctrine\ORM\Mapping\ClassMetadata->validateAndCompleteFieldMapping(object(FieldMapping)) (/application/vendor/doctrine/orm/src/Mapping/ClassMetadata.php:1936) at Doctrine\ORM\Mapping\ClassMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'scale' => null, 'length' => null, 'unique' => false, 'nullable' => false, 'index' => false, 'precision' => null, 'id' => true)) (/application/vendor/doctrine/orm/src/Mapping/Driver/AttributeDriver.php:329) at Doctrine\ORM\Mapping\Driver\AttributeDriver->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata)) (/application/vendor/doctrine/persistence/src/Persistence/Mapping/Driver/MappingDriverChain.php:61) at Doctrine\Persistence\Mapping\Driver\MappingDriverChain->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata)) (/application/vendor/doctrine/doctrine-bundle/src/Mapping/MappingDriver.php:41) at Doctrine\Bundle\DoctrineBundle\Mapping\MappingDriver->loadMetadataForClass('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment', object(ClassMetadata)) (/application/vendor/doctrine/orm/src/Mapping/ClassMetadataFactory.php:167) at Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), object(ClassMetadata), true, array('App\\Main\\Domain\\Model\\Attachment\\AbstractAttachment')) (/application/vendor/doctrine/doctrine-bundle/src/Mapping/ClassMetadataFactory.php:20) at Doctrine\Bundle\DoctrineBundle\Mapping\ClassMetadataFactory->doLoadMetadata(object(ClassMetadata), object(ClassMetadata), true, array('App\\Main\\Domain\\Model\\Attachment\\AbstractAttachment')) (/application/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:318) at Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment') (/application/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php:187) at Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('App\\Main\\Domain\\Model\\AirCompany\\AirCompanyAttachment') (/application/vendor/doctrine/orm/src/Tools/SchemaValidator.php:130) at Doctrine\ORM\Tools\SchemaValidator->validateClass(object(ClassMetadata)) (/application/vendor/doctrine/doctrine-bundle/src/DataCollector/DoctrineDataCollector.php:108) at Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector->collect(object(Request), object(Response), object(MappingException)) (/application/vendor/symfony/http-kernel/Profiler/Profiler.php:158) at Symfony\Component\HttpKernel\Profiler\Profiler->collect(object(Request), object(Response), object(MappingException)) (/application/vendor/symfony/http-kernel/EventListener/ProfilerListener.php:102) at Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher)) (/application/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ResponseEvent), 'kernel.response', object(TraceableEventDispatcher)) (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:206) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.response', object(ResponseEvent)) (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ResponseEvent), 'kernel.response') (/application/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:126) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ResponseEvent), 'kernel.response') (/application/vendor/symfony/http-kernel/HttpKernel.php:216) at Symfony\Component\HttpKernel\HttpKernel->filterResponse(object(Response), object(Request), 2) (/application/vendor/symfony/http-kernel/HttpKernel.php:204) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 2) (/application/vendor/symfony/http-kernel/HttpKernel.php:76) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 2, false) (/application/vendor/symfony/http-kernel/EventListener/ErrorListener.php:99) at Symfony\Component\HttpKernel\EventListener\ErrorListener->onKernelException(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher)) (/application/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher)) (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:206) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(ExceptionEvent)) (/application/vendor/symfony/event-dispatcher/EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception') (/application/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:126) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception') (/application/vendor/symfony/http-kernel/HttpKernel.php:241) at Symfony\Component\HttpKernel\HttpKernel->handleThrowable(object(MappingException), object(Request), 1) (/application/vendor/symfony/http-kernel/HttpKernel.php:134) at Symfony\Component\HttpKernel\HttpKernel->terminateWithException(object(MappingException), object(Request)) (/application/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:84) at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::{closure:Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure():78}(object(MappingException)) (/application/vendor/symfony/error-handler/ErrorHandler.php:538) at Symfony\Component\ErrorHandler\ErrorHandler->handleException(object(MappingException)) ```
Author
Owner

@stof commented on GitHub (Oct 28, 2025):

Does it work fine if you define AbstractBase as a MappedSuperclass ?

Maybe having inherited mapped properties coming from classes that are not mapped by Doctrine does not work well with entity inheritance.

the expected usage of Doctrine is that mapped properties should be declared in mapped classes (either entities or mapped super-classes)

@stof commented on GitHub (Oct 28, 2025): Does it work fine if you define `AbstractBase` as a `MappedSuperclass` ? Maybe having inherited mapped properties coming from classes that are not mapped by Doctrine does not work well with entity inheritance. the expected usage of Doctrine is that mapped properties should be declared in mapped classes (either entities or mapped super-classes)
Author
Owner

@davidnectarestudio commented on GitHub (Oct 29, 2025):

Does it work fine if you define AbstractBase as a MappedSuperclass ?

still failing even with var/cache/* hard remove

@davidnectarestudio commented on GitHub (Oct 29, 2025): > Does it work fine if you define `AbstractBase` as a `MappedSuperclass` ? still failing even with `var/cache/*` hard remove
Author
Owner

@davidnectarestudio commented on GitHub (Oct 29, 2025):

I doesn't change my source code since previous v3.5.2 and was working fine

@davidnectarestudio commented on GitHub (Oct 29, 2025): I doesn't change my source code since previous `v3.5.2` and was working fine
Author
Owner

@mpdude commented on GitHub (Oct 30, 2025):

Maybe it was #12212? AbstractBase must be a MappedSuperclass either way

@mpdude commented on GitHub (Oct 30, 2025): Maybe it was #12212? `AbstractBase` must be a MappedSuperclass either way
Author
Owner

@davidnectarestudio commented on GitHub (Oct 30, 2025):

@mpdude thanks for your hint, but even with or without MappedSuperclass still failing:

namespace App\Shared\Domain\Model;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\MappedSuperclass]
abstract class AbstractBase implements \Stringable
{
@davidnectarestudio commented on GitHub (Oct 30, 2025): @mpdude thanks for your hint, but even with or without `MappedSuperclass` still failing: ```php namespace App\Shared\Domain\Model; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\MappedSuperclass] abstract class AbstractBase implements \Stringable { ```
Author
Owner

@mpdude commented on GitHub (Oct 30, 2025):

#11404, #11488 report similar errors

@mpdude commented on GitHub (Oct 30, 2025): #11404, #11488 report similar errors
Author
Owner

@davidnectarestudio commented on GitHub (Nov 5, 2025):

@mpdude I've copied this code into Doctrine\ORM\Mapping\Driver\ReflectionBasedDriver again after v3.5.3 update, and all is working as usually

if ($this->isTransient($declaringClass)) {
    return isset($metadata->fieldMappings[$property->name]);
}
@davidnectarestudio commented on GitHub (Nov 5, 2025): @mpdude I've copied this code into `Doctrine\ORM\Mapping\Driver\ReflectionBasedDriver` again after v3.5.3 update, and all is working as usually ```php if ($this->isTransient($declaringClass)) { return isset($metadata->fieldMappings[$property->name]); } ```
Author
Owner

@mpdude commented on GitHub (Nov 5, 2025):

That does not make the code more correct 🫠

There must be a mapping misconfiguration somewhere in your code, where you have mapping attributes in a class that is neither an entity nor a mapped superclass.

@mpdude commented on GitHub (Nov 5, 2025): That does not make the code more correct 🫠 There must be a mapping misconfiguration somewhere in your code, where you have mapping attributes in a class that is neither an entity nor a mapped superclass.
Author
Owner

@davidnectarestudio commented on GitHub (Nov 6, 2025):

namespace App\Shared\Domain\Model;

abstract class AbstractBase implements \Stringable
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: Types::INTEGER)]
    protected ?int $id = null;
namespace App\Main\Domain\Model\Attachment;

#[ORM\Entity(repositoryClass: AbstractAttachmentRepositoryInterface::class)]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')]
#[ORM\DiscriminatorMap([
    'attachment' => Attachment::class,
    'air_company' => AirCompanyAttachment::class,
    'rate' => RateAttachment::class,
])]
#[ORM\Table(name: 'attachment')]
abstract class AbstractAttachment extends AbstractBase implements AbstractAttachmentInterface
{
    #[ORM\Column(type: Types::STRING, length: 200)]
    protected ?string $size;
<?php

namespace App\Main\Domain\Model\AirCompany;

#[ORM\Entity(repositoryClass: AirCompanyAttachmentRepository::class)]
class AirCompanyAttachment extends AbstractAttachment
{
    #[Vich\UploadableField(mapping: 'air_company_attachments', fileNameProperty: 'vichFileName', size: 'size', mimeType: 'mimeType', originalName: 'path', dimensions: 'vichFileDimensions')]
    protected ?File $vichFile = null;
}

@mpdude where is the right place to put the MappedSuperClass attribute? Into AbstractBase or AbstractAttachment? Keep in mind that both are abstract classes...

@davidnectarestudio commented on GitHub (Nov 6, 2025): ```php namespace App\Shared\Domain\Model; abstract class AbstractBase implements \Stringable { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: Types::INTEGER)] protected ?int $id = null; ``` ```php namespace App\Main\Domain\Model\Attachment; #[ORM\Entity(repositoryClass: AbstractAttachmentRepositoryInterface::class)] #[ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'type', type: 'string')] #[ORM\DiscriminatorMap([ 'attachment' => Attachment::class, 'air_company' => AirCompanyAttachment::class, 'rate' => RateAttachment::class, ])] #[ORM\Table(name: 'attachment')] abstract class AbstractAttachment extends AbstractBase implements AbstractAttachmentInterface { #[ORM\Column(type: Types::STRING, length: 200)] protected ?string $size; ``` ```php <?php namespace App\Main\Domain\Model\AirCompany; #[ORM\Entity(repositoryClass: AirCompanyAttachmentRepository::class)] class AirCompanyAttachment extends AbstractAttachment { #[Vich\UploadableField(mapping: 'air_company_attachments', fileNameProperty: 'vichFileName', size: 'size', mimeType: 'mimeType', originalName: 'path', dimensions: 'vichFileDimensions')] protected ?File $vichFile = null; } ``` @mpdude where is the right place to put the `MappedSuperClass` attribute? Into `AbstractBase` or `AbstractAttachment`? Keep in mind that both are abstract classes...
Author
Owner

@mpdude commented on GitHub (Nov 11, 2025):

AbstractBase

I note all your classes come from different namespaces. Also that’s a pattern I’ve seen in other bug reports before.

@mpdude commented on GitHub (Nov 11, 2025): `AbstractBase` I note all your classes come from different namespaces. Also that’s a pattern I’ve seen in other bug reports before.
Author
Owner

@davidnectarestudio commented on GitHub (Nov 12, 2025):

Yes, indeed I've 3 different entity managers as well, and this is the reason becuase I want to keep an AbstractBase into a shared namespace. Maybe the problem is related with this kind of config? I need to acces 3 different databases located in same server:

doctrine:
    dbal:
        types:
            uuid_text: 'App\Shared\Infrastructure\Doctrine\Type\UuidTextType'
        default_connection: 'default'
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
                profiling_collect_backtrace: '%kernel.debug%'
                use_savepoints: true
            crm:
                url: '%env(resolve:DATABASE_CRM_URL)%'
                profiling_collect_backtrace: '%kernel.debug%'
                use_savepoints: true
            externals:
                url: '%env(resolve:DATABASE_EXTERNALS_URL)%'
                profiling_collect_backtrace: '%kernel.debug%'
                use_savepoints: true
    orm:
        auto_generate_proxy_classes: true
        enable_native_lazy_objects: true
        default_entity_manager: 'default'
        entity_managers:
            default:
                connection: 'default'
                report_fields_where_declared: true
                validate_xml_mapping: true
                naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware'
                mappings:
                    App:
                        is_bundle: false
                        type: 'attribute'
                        dir: '%kernel.project_dir%/src/Main/Domain/Model'
                        prefix: 'App\Main\Domain\Model'
                        alias: 'App'
            crm:
                connection: 'crm'
                report_fields_where_declared: true
                validate_xml_mapping: true
                naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware'
                mappings:
                    CrmApp:
                        is_bundle: false
                        type: 'attribute'
                        dir: '%kernel.project_dir%/src/Crm/Domain/Model'
                        prefix: 'App\Crm\Domain\Model'
                        alias: 'CrmApp'
            externals:
                connection: 'externals'
                report_fields_where_declared: true
                validate_xml_mapping: true
                naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware'
                mappings:
                    ExternalApp:
                        is_bundle: false
                        type: 'attribute'
                        dir: '%kernel.project_dir%/src/Externals/Domain/Model'
                        prefix: 'App\Externals\Domain\Model'
                        alias: 'ExternalApp'
        controller_resolver:
            auto_mapping: false
@davidnectarestudio commented on GitHub (Nov 12, 2025): Yes, indeed I've 3 different entity managers as well, and this is the reason becuase I want to keep an `AbstractBase` into a shared namespace. Maybe the problem is related with this kind of config? I need to acces 3 different databases located in same server: ```yaml doctrine: dbal: types: uuid_text: 'App\Shared\Infrastructure\Doctrine\Type\UuidTextType' default_connection: 'default' connections: default: url: '%env(resolve:DATABASE_URL)%' profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true crm: url: '%env(resolve:DATABASE_CRM_URL)%' profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true externals: url: '%env(resolve:DATABASE_EXTERNALS_URL)%' profiling_collect_backtrace: '%kernel.debug%' use_savepoints: true orm: auto_generate_proxy_classes: true enable_native_lazy_objects: true default_entity_manager: 'default' entity_managers: default: connection: 'default' report_fields_where_declared: true validate_xml_mapping: true naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware' mappings: App: is_bundle: false type: 'attribute' dir: '%kernel.project_dir%/src/Main/Domain/Model' prefix: 'App\Main\Domain\Model' alias: 'App' crm: connection: 'crm' report_fields_where_declared: true validate_xml_mapping: true naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware' mappings: CrmApp: is_bundle: false type: 'attribute' dir: '%kernel.project_dir%/src/Crm/Domain/Model' prefix: 'App\Crm\Domain\Model' alias: 'CrmApp' externals: connection: 'externals' report_fields_where_declared: true validate_xml_mapping: true naming_strategy: 'doctrine.orm.naming_strategy.underscore_number_aware' mappings: ExternalApp: is_bundle: false type: 'attribute' dir: '%kernel.project_dir%/src/Externals/Domain/Model' prefix: 'App\Externals\Domain\Model' alias: 'ExternalApp' controller_resolver: auto_mapping: false ```
Author
Owner

@davidnectarestudio commented on GitHub (Dec 18, 2025):

solved

@davidnectarestudio commented on GitHub (Dec 18, 2025): solved
Author
Owner

@mpdude commented on GitHub (Dec 18, 2025):

And the reason was...?

Share your learning experience :)

@mpdude commented on GitHub (Dec 18, 2025): And the reason was...? Share your learning experience :)
Author
Owner

@davidnectarestudio commented on GitHub (Dec 19, 2025):

Well, the main problem seems that #[ORM\MappedSuperclass] must be applied into an abstract class located under same namespace root.

We've solved just moving our AbstractBase from App\Shared\Domain\Model to App\Main\Domain\Model (where lives the class that implements ORM\InheritanceType)

Before v3.5.3 no error thrown, but I'm not 100% sure that was fully working too, because I've discovered that the discriminator column type was empty.

#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')]

Now we are updated to the latest version and the type column is filled according to the extended class.

@davidnectarestudio commented on GitHub (Dec 19, 2025): Well, the main problem seems that `#[ORM\MappedSuperclass]` must be applied into an abstract class located under same namespace root. We've solved just moving our `AbstractBase` from `App\Shared\Domain\Model` to `App\Main\Domain\Model` (where lives the class that implements `ORM\InheritanceType`) Before v3.5.3 no error thrown, but I'm not 100% sure that was fully working too, because I've discovered that the discriminator column `type` was empty. ```php #[ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'type', type: 'string')] ``` Now we are updated to the latest version and the `type` column is filled according to the extended class.
Author
Owner

@stof commented on GitHub (Dec 19, 2025):

Well, the main problem seems that #[ORM\MappedSuperclass] must be applied into an abstract class located under same namespace root.

this is not true. It must be applied in a class located in a namespace registered in the mapping configuration of the entity manager. But it can be a different namespace than the entity.

@stof commented on GitHub (Dec 19, 2025): > Well, the main problem seems that `#[ORM\MappedSuperclass]` must be applied into an abstract class located under same namespace root. this is not true. It must be applied in a class located in a namespace registered in the mapping configuration of the entity manager. But it can be a different namespace than the entity.
Author
Owner

@davidnectarestudio commented on GitHub (Dec 19, 2025):

Ok, now I can see the real problem, thx @stof

The initial abstract class was located inside a namespace that was not registered.

@davidnectarestudio commented on GitHub (Dec 19, 2025): Ok, now I can see the real problem, thx @stof The initial abstract class was located inside a namespace that was not registered.
Author
Owner

@mpdude commented on GitHub (Dec 19, 2025):

😅 Good to hear that.

I was afraid that there might be in fact a bigger issue for a future me, given the other two similar-looking reports #11404 and #11488, plus I have an internal issue pending investigation where a co-worker made similar claims.

@mpdude commented on GitHub (Dec 19, 2025): 😅 Good to hear that. I was afraid that there might be in fact a bigger issue for a future me, given the other two similar-looking reports #11404 and #11488, plus I have an internal issue pending investigation where a co-worker made similar claims.
Author
Owner

@pounard commented on GitHub (Jan 21, 2026):

The initial abstract class was located inside a namespace that was not registered.

Yes, exactly what I found out as well! See https://github.com/doctrine/orm/issues/11404#issuecomment-3773456042

This behavior was changed between 2.x and 3.x, because in 2.x it was working nicely, the MappingDriver didn't care where the parent class was located and was processing it using the child class driver configuration.

@pounard commented on GitHub (Jan 21, 2026): > The initial abstract class was located inside a namespace that was not registered. Yes, exactly what I found out as well! See https://github.com/doctrine/orm/issues/11404#issuecomment-3773456042 This behavior was changed between 2.x and 3.x, because in 2.x it was working nicely, the MappingDriver didn't care where the parent class was located and was processing it using the child class driver configuration.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7567