Deprecation false positive(?): Embeddable reported to require inheritance mapping type #7478

Open
opened 2026-01-22 15:52:10 +01:00 by admin · 2 comments
Owner

Originally created by @havvg on GitHub (Feb 20, 2025).

Bug Report

Q A
Version 2.20.2

Summary

We are currently migrating a project to Doctrine 3 and are encountering the following deprecation.

Entity class 'App\Domain\Value\BoundedTimeframe' is a subclass of the root entity class 'App\Domain\Value\Timeframe', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0. (ClassMetadataFactory.php:165 called by ClassMetadataFactory.php:18, https://github.com/doctrine/orm/pull/10431, package doctrine/orm)

Current behavior

The deprecation about entity inheritance is raised on embeddables.

Expected behavior

There has been no issue within Doctrine 2 using this pattern. As you cannot define inheritance types on embeddables, the deprecation should not be raised for them. In addition, the behavior should work in Doctrine 3, as well. Will it?

How to reproduce

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <embeddable name="App\Domain\Value\Timeframe">
        <field name="from" type="datetime_immutable" column="from" nullable="true" />
        <field name="to" type="datetime_immutable" column="to" nullable="true" />
    </embeddable>
</doctrine-mapping>
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <embeddable name="App\Domain\Value\BoundedTimeframe" />
</doctrine-mapping>
// Simplified

class Timeframe
{
    public function __construct(
        protected readonly \DateTimeImmutable|null $from,
        protected readonly \DateTimeImmutable|null $to,
    ) {
    }
}

class BoundedTimeframe extends Timeframe
{
    public function __construct(\DateTimeImmutable $from, \DateTimeImmutable $to)
    {
        parent::__construct($from, $to);
    }
}
Originally created by @havvg on GitHub (Feb 20, 2025). ### Bug Report | Q | A |-------------------------------------------- | ------ | Version | 2.20.2 #### Summary We are currently migrating a project to Doctrine 3 and are encountering the following deprecation. ``` Entity class 'App\Domain\Value\BoundedTimeframe' is a subclass of the root entity class 'App\Domain\Value\Timeframe', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0. (ClassMetadataFactory.php:165 called by ClassMetadataFactory.php:18, https://github.com/doctrine/orm/pull/10431, package doctrine/orm) ``` #### Current behavior The deprecation about entity inheritance is raised on embeddables. #### Expected behavior There has been no issue within Doctrine 2 using this pattern. As you cannot define inheritance types on embeddables, the deprecation should not be raised for them. In addition, the behavior should work in Doctrine 3, as well. Will it? #### How to reproduce ```xml <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <embeddable name="App\Domain\Value\Timeframe"> <field name="from" type="datetime_immutable" column="from" nullable="true" /> <field name="to" type="datetime_immutable" column="to" nullable="true" /> </embeddable> </doctrine-mapping> ``` ```xml <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <embeddable name="App\Domain\Value\BoundedTimeframe" /> </doctrine-mapping> ``` ```php // Simplified class Timeframe { public function __construct( protected readonly \DateTimeImmutable|null $from, protected readonly \DateTimeImmutable|null $to, ) { } } class BoundedTimeframe extends Timeframe { public function __construct(\DateTimeImmutable $from, \DateTimeImmutable $to) { parent::__construct($from, $to); } } ```
admin added the Bug label 2026-01-22 15:52:10 +01:00
Author
Owner

@greg0ire commented on GitHub (Feb 26, 2025):

Possible next steps:

@greg0ire commented on GitHub (Feb 26, 2025): Possible next steps: - convert the provided reproducer to a test - address the issue by adding a condition on `$class->isEmbeddedClass` to the code added in https://github.com/doctrine/orm/pull/10431
Author
Owner

@havvg commented on GitHub (Mar 7, 2025):

My current workaround is to simply add inheritance-type="JOINED". While this silences the deprecation, it does not seem to have any effect at runtime. This also works with Doctrine v3.3.2.

<embeddable name="App\Domain\Value\Timeframe" inheritance-type="JOINED">
@havvg commented on GitHub (Mar 7, 2025): My current workaround is to simply add `inheritance-type="JOINED"`. While this silences the deprecation, it does not seem to have any effect at runtime. This also works with Doctrine v3.3.2. ```xml <embeddable name="App\Domain\Value\Timeframe" inheritance-type="JOINED"> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7478