Relationships with @Embedded column #5901

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

Originally created by @ivaaaan on GitHub (Feb 25, 2018).

Originally assigned to: @Ocramius on GitHub.

Environment: PHP 7.1.7
Doctrine: 2.6
Symfony: 4

I have @Embeddable class for id:

<?php

/**
* @ORM\Embeddable()
*/
class Id
{
    /**
    * @ORM\Id()
    * @ORM\Column(type="string")
    */
    private $id;
    
    //getters, setters, etc
}

And two classes that have @ManyToOne relationship:

<?php

/**
* @ORM\Entity()
*/
class Gist
{
    /**
    * @var Id
    *
    * @ORM\Id()
    * @ORM\Embedded(class="App\Entity\Id")
    */
    private $id;
    
    /**
    * @var User
    *
    * @ORM\ManyToOne(targetEntity="App\Entity\User")
    */
    private $user;

//getters, setters, etc
}

And User class:

<?php
/**
* @ORM\Entity()
*/
class User implements UserInterface
{
    /**
    * @var Id
    *
    * @ORM\Embedded(class="App\Entity\Id")
    *
    */
    private $id;
    
    //getters, setters, etc

}

When I trying to create schema I got error: No mapping found for field 'id' on class 'App\Entity\User'..

Originally created by @ivaaaan on GitHub (Feb 25, 2018). Originally assigned to: @Ocramius on GitHub. Environment: PHP 7.1.7 Doctrine: 2.6 Symfony: 4 I have `@Embeddable` class for id: ```php <?php /** * @ORM\Embeddable() */ class Id { /** * @ORM\Id() * @ORM\Column(type="string") */ private $id; //getters, setters, etc } ``` And two classes that have `@ManyToOne` relationship: ```php <?php /** * @ORM\Entity() */ class Gist { /** * @var Id * * @ORM\Id() * @ORM\Embedded(class="App\Entity\Id") */ private $id; /** * @var User * * @ORM\ManyToOne(targetEntity="App\Entity\User") */ private $user; //getters, setters, etc } ``` And `User` class: ```php <?php /** * @ORM\Entity() */ class User implements UserInterface { /** * @var Id * * @ORM\Embedded(class="App\Entity\Id") * */ private $id; //getters, setters, etc } ``` When I trying to create schema I got error: `No mapping found for field 'id' on class 'App\Entity\User'.`.
admin added the Question label 2026-01-22 15:21:32 +01:00
admin closed this issue 2026-01-22 15:21:33 +01:00
Author
Owner

@Ocramius commented on GitHub (Feb 25, 2018):

Support of identifiers within @Embeddable is not really there yet, sorry.

@Ocramius commented on GitHub (Feb 25, 2018): Support of identifiers within `@Embeddable` is not really there yet, sorry.
Author
Owner

@ivaaaan commented on GitHub (Feb 25, 2018):

@Ocramius so sad. any plans to realize that?

@ivaaaan commented on GitHub (Feb 25, 2018): @Ocramius so sad. any plans to realize that?
Author
Owner

@Ocramius commented on GitHub (Feb 25, 2018):

Nope, but you can attempt sending a patch :)

@Ocramius commented on GitHub (Feb 25, 2018): Nope, but you can attempt sending a patch :)
Author
Owner

@IvoPereira commented on GitHub (Nov 18, 2021):

Were there any developments on this meanwhile @Ocramius?

@IvoPereira commented on GitHub (Nov 18, 2021): Were there any developments on this meanwhile @Ocramius?
Author
Owner

@Ocramius commented on GitHub (Nov 18, 2021):

No, you would see a public issue/PR for it otherwise.

In open source, you pick it up yourself, @IvoPereira.

@Ocramius commented on GitHub (Nov 18, 2021): No, you would see a public issue/PR for it otherwise. In open source, you pick it up yourself, @IvoPereira.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5901