title: Symfony4 Mapping issue
body: <p>I got an error like:</p>
  
  <blockquote>
  <pre><code>Undefined index: id
  </code></pre>
  </blockquote>
  
  <p>I know there are few questions like that already present on a Stack Overflow, but the solutions didn't work for me. Could you please review my entities in order of figuring out what exactly is causing this issue?</p>
  
  <p><strong>User</strong></p>
  
  <pre><code>namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  use Symfony\Component\Validator\Constraints as Assert;
  use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
   * @ORM\HasLifecycleCallbacks()
   * @UniqueEntity("email")
   */
  class User
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Assert\NotBlank()
       */
      private $user_name;
  
      /**
       * @ORM\Column(type="string", length=100)
       */
      private $first_name;
  
      /**
       * @ORM\Column(type="string", length=100)
       */
      private $last_name;
  
      /**
       * @ORM\Column(type="string", length=255, unique=true)
       * @Assert\NotBlank()
       * @Assert\Email()
       */
      private $email;
  
      /**
       * @ORM\Column(type="string", length=20, nullable=true)
       */
      private $phone_number;
  
      /**
       * @ORM\Column(type="string", length=20, nullable=true)
       */
      private $cell_phone_number;
  
      /**
       * @ORM\Column(type="boolean")
       */
      private $enabled;
  
      /**
       * @ORM\Column(type="string", length=100)
       * @Assert\NotBlank()
       */
      private $timezone;
  
      /**
       * @ORM\Column(type="string", length=40)
       */
      private $password;
  
      /**
       * @ORM\Column(type="datetime", nullable=true)
       */
      private $last_login;
  
      /**
       * @var \DateTime $created
       *
       * @ORM\Column(type="datetime")
       */
      private $created;
  
      /**
       * @var \DateTime $updated
       *
       * @ORM\Column(type="datetime", nullable=true)
       */
      private $updated;
  
      /**
       * Many Users have Many Groups.
       * @ORM\ManyToMany(targetEntity="Group")
       * @ORM\JoinTable(name="user_group",
       *     joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
       *     inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
       * )
       */
      private $group;
  
      /**
       * Many Users have Many Roles.
       * @ORM\ManyToMany(targetEntity="Role", cascade={"persist"})
       * @ORM\JoinTable(name="user_role",
       *     joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
       *     inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
       * )
       */
      private $role;
  
  
      public function __construct() {
          $this-&gt;enabled = 0;
          $this-&gt;group = new ArrayCollection();
          $this-&gt;role = new ArrayCollection();
      }
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getUsername(): ?string
      {
          return $this-&gt;user_name;
      }
  
      public function setUsername(string $user_name): self
      {
          $this-&gt;user_name = $user_name;
  
          return $this;
      }
  
      public function getEmail(): ?string
      {
          return $this-&gt;email;
      }
  
      public function setEmail(?string $email): self
      {
          $this-&gt;email = $email;
  
          return $this;
      }
  
      public function getEnabled(): ?bool
      {
          return $this-&gt;enabled;
      }
  
      public function setEnabled(bool $enabled): self
      {
          $this-&gt;enabled = $enabled;
  
          return $this;
      }
  
      public function getTimezone(): ?string
      {
          return $this-&gt;timezone;
      }
  
      public function setTimezone(string $timezone): self
      {
          $this-&gt;timezone = $timezone;
  
          return $this;
      }
  
      public function getPassword(): ?string
      {
          return $this-&gt;password;
      }
  
      public function setPassword(string $password): self
      {
          $this-&gt;password = $password;
  
          return $this;
      }
  
      public function getLastLogin(): ?\DateTimeInterface
      {
          return $this-&gt;last_login;
      }
  
      public function setLastLogin(?\DateTimeInterface $last_login): self
      {
          $this-&gt;last_login = $last_login;
  
          return $this;
      }
  
      public function getPhoneNumber(): ?string
      {
          return $this-&gt;phone_number;
      }
  
      public function setPhoneNumber(?string $phone_number): self
      {
          $this-&gt;phone_number = $phone_number;
  
          return $this;
      }
  
      /**
       * @Assert\IsTrue(message="The password cannot match your first name")
       */
      public function isPasswordSafe()
      {
          return $this-&gt;user_name !== $this-&gt;password;
      }
  
      /**
       * @ORM\PrePersist
       */
      public function setCreated()
      {
          $this-&gt;created = new \DateTime();
      }
  
      public function getCreated()
      {
          return $this-&gt;created;
      }
  
      /**
       * @ORM\PreUpdate
       */
      public function setUpdated()
      {
          $this-&gt;updated = new \DateTime();
      }
  
      public function getUpdated()
      {
          return $this-&gt;updated;
      }
  
      public function getGroups()
      {
          return $this-&gt;group;
      }
  
      public function getRoles()
      {
          return $this-&gt;role;
      }
  
      public function addRoles(Role $role)
      {
          // updating inverse side
          $role-&gt;addUser($this);
          $this-&gt;role[] = $role;
      }
  
      public function getFirstName(): ?string
      {
          return $this-&gt;first_name;
      }
  
      public function setFirstName(string $first_name): self
      {
          $this-&gt;first_name = $first_name;
  
          return $this;
      }
  
      public function getLastName(): ?string
      {
          return $this-&gt;last_name;
      }
  
      public function setLastName(string $last_name): self
      {
          $this-&gt;last_name = $last_name;
  
          return $this;
      }
  
      public function getCellPhoneNumber(): ?string
      {
          return $this-&gt;cell_phone_number;
      }
  
      public function setCellPhoneNumber(?string $cell_phone_number): self
      {
          $this-&gt;cell_phone_number = $cell_phone_number;
  
          return $this;
      }
  }
  </code></pre>
  
  <p><strong>Group</strong></p>
  
  <pre><code>namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\GroupRepository")
   */
  class Group
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $group_name;
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getGroupName(): ?string
      {
          return $this-&gt;group_name;
      }
  
      public function setGroupName(string $group_name): self
      {
          $this-&gt;group_name = $group_name;
  
          return $this;
      }
  }
  </code></pre>
  
  <p><strong>Role</strong></p>
  
  <pre><code>namespace App\Entity;
  
  use App\Entity\User;
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\RoleRepository")
   */
  class Role
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255, unique=true)
       */
      private $role_name;
  
      /**
       * Many Roles have Many Permissions.
       * @ORM\ManyToMany(targetEntity="Permission")
       * @ORM\JoinTable(name="role_permission",
       *     joinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")},
       *     inverseJoinColumns={@ORM\JoinColumn(name="permission_id", referencedColumnName="id")}
       * )
       */
      private $permission;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=true)
       */
      private $description;
  
      private $user;
  
      public function __construct() {
          $this-&gt;user = new ArrayCollection();
          $this-&gt;permission = new ArrayCollection();
      }
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getRolename(): ?string
      {
          return $this-&gt;role_name;
      }
  
      public function setRolename(string $role_name): self
      {
          $this-&gt;role_name = $role_name;
  
          return $this;
      }
  
      public function getDescription(): ?string
      {
          return $this-&gt;description;
      }
  
      public function setDescription(?string $description): self
      {
          $this-&gt;description = $description;
  
          return $this;
      }
  
      public function addUser(User $user)
      {
          $this-&gt;user[] = $user;
      }
  }
  </code></pre>
  
  <p><strong>Controller method</strong></p>
  
  <pre><code>/**
   * @Route("/user/{id}", methods={"GET","HEAD"})
   * @SWG\Response(
   *     response=200,
   *     description="Returns a user or users",
   *     @SWG\Schema(
   *         type="array",
   *         @SWG\Items(ref=@Model(type=User::class, groups={"full"}))
   *     )
   * )
   * @SWG\Tag(name="user")
   */
  public function get(string $id)
  {
      $repo = $this-&gt;userRepository;
      $user = $repo-&gt;find($id);
  
      return [
          'user' =&gt; $user
      ];
  }
  </code></pre>
  
  <p><strong>Trace</strong></p>
  
  <blockquote>
    <p>/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(2607):
    Doctrine\ORM\Utility\IdentifierFlattener->flattenIdentifier(Object(Doctrine\ORM\Mapping\ClassMetadata),
    Array)
    /vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php(146):
    Doctrine\ORM\UnitOfWork->createEntity('App\Entity\User', Array,
    Array)
    /vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php(68):
    Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateRowData(Array,
    Array)
    /vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php(152):
    Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateAllData()
    /vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(741):
    Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll(Object(Doctrine\DBAL\Driver\PDOStatement),
    Object(Doctrine\ORM\Query\ResultSetMapping), Array)
    /vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php(751):
    Doctrine\ORM\Persisters\Entity\BasicEntityPersister->load(Array, NULL)
    /vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(460):
    Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadById(Array)
    /vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php(154):
    Doctrine\ORM\EntityManager->find('App\Entity\User', Array, NULL,
    NULL) /src/Controller/UserController.php(61):
    Doctrine\ORM\EntityRepository->find('1')
    /vendor/symfony/http-kernel/HttpKernel.php(149):
    App\Controller\UserController->get('1')
    /vendor/symfony/http-kernel/HttpKernel.php(66):
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request),
    1) /vendor/symfony/http-kernel/Kernel.php(188):
    Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request),
    1, true) /public/index.php(37):
    Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    {main}</p>
  </blockquote>
  
  <p><strong>SOLVED!</strong></p>
  
  <p>The issue was caused by redefined <code>QuoteStrategy::getColumnAlias()</code> method
  because "`" was added to query.</p>