DDC-432: @JoinTable and @JoinColumn annotation name attributes miss joined entity name first char #539

Closed
opened 2026-01-22 12:41:48 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 16, 2010).

Originally assigned to: @jwage on GitHub.

Jira issue originally created by user floch:

When generating php classes from YAML (via orm:convert-mapping cli tool) with maping default, the name of the joined table is incorrect.

yaml:

Entities\User:
  type: entity
  table: users
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    login:
      type: name
      length: 60
      unique: true
  manyToMany:
    roles:
    email:
      targetEntity: Email

Entities\Email:
  type: entity
  table: emails
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    type:
      type: string
      length: 32
    email:
      type: string
      length: 100

produced php classes; note @JoinTable(name="User_mail" and @JoinColumn(name="mail_id"; The E of Email is missing :

<?php

namespace Entities;


/****
 * @Entity
 * @Table(name="users")
 * 
 * 
 * 
 */
class User{
    /****
     * @Column(name="id", type="integer")
     * @Id
     * @GeneratedValue(strategy="AUTO")
     */
    private $id;

    /****
     * @Column(name="name", type="string", length=60, unique=true)
     */
    private $name;

    /****
     * @ManyToMany(targetEntity="Email")
     * @JoinTable(name="User_mail",
     *   joinColumns={
     *     @JoinColumn(name="User_id", referencedColumnName="id")
     *   },
     *   inverseJoinColumns={
     *     @JoinColumn(name="mail_id", referencedColumnName="id")
     *   }
     * )
     */
    private $email = array() ;

    /****
     * Get id
     */
    public function getId()
    {
        return $this->id;
    }

    /****
     * Set name
     */
    public function setName($value)
    {
        $this->name = $value;
    }

    /****
     * Get name
     */
    public function getName()
    {
        return $this->name;
    }

    /****
     * Add email
     */
    public function addEmail($value)
    {
        $this->email[] = $value;
    }

    /****
     * Get email
     */
    public function getEmail()
    {
        return $this->email;
    }
}
Originally created by @doctrinebot on GitHub (Mar 16, 2010). Originally assigned to: @jwage on GitHub. Jira issue originally created by user floch: When generating php classes from YAML (via orm:convert-mapping cli tool) with maping default, the name of the joined table is incorrect. yaml: ``` Entities\User: type: entity table: users id: id: type: integer generator: strategy: AUTO fields: login: type: name length: 60 unique: true manyToMany: roles: email: targetEntity: Email Entities\Email: type: entity table: emails id: id: type: integer generator: strategy: AUTO fields: type: type: string length: 32 email: type: string length: 100 ``` produced php classes; note @JoinTable(name="User_mail" and @JoinColumn(name="mail_id"; The E of Email is missing : ``` <?php namespace Entities; /**** * @Entity * @Table(name="users") * * * */ class User{ /**** * @Column(name="id", type="integer") * @Id * @GeneratedValue(strategy="AUTO") */ private $id; /**** * @Column(name="name", type="string", length=60, unique=true) */ private $name; /**** * @ManyToMany(targetEntity="Email") * @JoinTable(name="User_mail", * joinColumns={ * @JoinColumn(name="User_id", referencedColumnName="id") * }, * inverseJoinColumns={ * @JoinColumn(name="mail_id", referencedColumnName="id") * } * ) */ private $email = array() ; /**** * Get id */ public function getId() { return $this->id; } /**** * Set name */ public function setName($value) { $this->name = $value; } /**** * Get name */ public function getName() { return $this->name; } /**** * Add email */ public function addEmail($value) { $this->email[] = $value; } /**** * Get email */ public function getEmail() { return $this->email; } } ```
admin added the Bug label 2026-01-22 12:41:48 +01:00
admin closed this issue 2026-01-22 12:41:49 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 17, 2010):

Comment created by @jwage:

Is your YAML schema correct? It looks wrong. You reference a target Entity of Email but it is Entities\Email. You also specify a key named "roles" but don't specify anything under it. When I try and convert your schema I get the error:

$ ./doctrine orm:convert-mapping --from=yaml --to=annotation --dest=Entities/
Doctrine Command Line Interface

Adding "yaml" mapping source which contains the "yml" format
orm:convert-mapping => The association mapping 'roles' misses the 'targetEntity' attribute.
@doctrinebot commented on GitHub (Mar 17, 2010): Comment created by @jwage: Is your YAML schema correct? It looks wrong. You reference a target Entity of Email but it is Entities\Email. You also specify a key named "roles" but don't specify anything under it. When I try and convert your schema I get the error: ``` $ ./doctrine orm:convert-mapping --from=yaml --to=annotation --dest=Entities/ Doctrine Command Line Interface Adding "yaml" mapping source which contains the "yml" format orm:convert-mapping => The association mapping 'roles' misses the 'targetEntity' attribute. ```
Author
Owner

@doctrinebot commented on GitHub (Mar 17, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Mar 17, 2010): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Mar 17, 2010):

Comment created by floch:

The 'roles' key shouldn't be here, i've copied my YAML and deleted most part so we could focus on what i was noticing; I forgot to take out this line.
Regarding the target entity, i don't know why but i was expecting that the name of the entity should be passed without its namespace, I guess i was wrong. Thanks for highlighting that point.

@doctrinebot commented on GitHub (Mar 17, 2010): Comment created by floch: The 'roles' key shouldn't be here, i've copied my YAML and deleted most part so we could focus on what i was noticing; I forgot to take out this line. Regarding the target entity, i don't know why but i was expecting that the name of the entity should be passed without its namespace, I guess i was wrong. Thanks for highlighting that point.
Author
Owner

@doctrinebot commented on GitHub (Mar 18, 2010):

Comment created by floch:

I actually used default YAML files provided in the sandbox to create mine.

In those files, entities are named after Entities<entity_name> but the relationship refers to <entity_name> only (w/o 'Entities').

In that case, regarding your comment about entities references, I presume that sandbox YAML schema is not correct either. Can you confirm that point?

Thanks!

@doctrinebot commented on GitHub (Mar 18, 2010): Comment created by floch: I actually used default YAML files provided in the sandbox to create mine. In those files, entities are named after Entities<entity_name> but the relationship refers to <entity_name> only (w/o 'Entities\'). In that case, regarding your comment about entities references, I presume that sandbox YAML schema is not correct either. Can you confirm that point? Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#539