DDC-1908: Symfony 2 Doctrine join tables error #2575

doctrinebot opened this Issue Jul 5, 2012 · 5 comments

2 participants


Jira issue originally created by user cfyzz:

Hello developers of Doctrine. I appreiate your work on a such complicated project. So seems I'found a bug in Doctrine in generating SQL
I had written this issue on Symfony forum but noone is answering, so maybe I've found the bug of Doctrine or FOSUserBundle
I'm using Symfony 2.0.12, so I've installed as git submodules FOSUserBundle, created User Entity with one-to-one relationship with Company Entity, here goes the code:


namespace AV\TradeBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;



    class User extends BaseUser
        @ORM\GeneratedValue(strategy="AUTO") */ protected $id;

        @var company *
        @ORM\OneToOne(targetEntity="Companies", mappedBy="user") ** **/ private $company;

    public function construct()
    // your own logic

    public function getCompany() {
    return $this->company;

    public function setCompany($company) {
    $this->company = $company;

and piece of Company Entity:

* @var user
* @ORM\OneToOne(targetEntity="user", inversedBy="company")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
private $user;

When creating fixtures I'm using such method (all references are set, and I have checked for foreign keys in DB - everything is fine)
When I'm trying to login I see such error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't46.id' in 'on clause'

The whole SELECT statement that I found in logs sounds like this one:

SELECT t0.username AS username1, t0.username*canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email*canonical4, t0.enabled AS enabled5,
 t0.salt AS salt6, t0.password AS password7, t0.last*login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires*at11, 
t0.confirmation*token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials*expired15,
 t0.credentials*expire_at AS credentials_expire_at16, t0.id AS id17, t18.id AS id19, t18.egrpou AS egrpou20, t18.business_form AS business*form21, t18.title AS title22, 
t18.phone*code AS phone_code23, t18.phone_country_code AS phone_country_code24, t18.phone AS phone25, t18.fax_code AS fax*code26, 
t18.fax*country_code AS fax_country_code27, t18.fax AS fax28, t18.website AS website29, t18.fio AS fio30, t18.birthday AS birthday31, t18.firm_created AS firm*created32, 
t18.employees*count AS employees_count33, t18.logo AS logo34, t18.zip AS zip35, t18.street AS street36, t18.position AS position37, t18.thumb_logo AS thumb*logo38, 
t18.description AS description39, t18.created*at AS created_at40, t18.email AS email41, t18.cities_id AS cities_id42, t18.regions_id AS regions_id43, t18.countries_id AS countries*id44,
 t18.user*id AS user_id45 FROM fos_user t0 LEFT JOIN companies t18 ON t18.user_id = t46.id WHERE t0.username*canonical = ? (["cfyzz"]) [] []

Does anyone know why it's not t0 in join condition but t46?
If needed I'll show my deps.lock, maybe such situation was already fixed, but I was googling for answer for several days - and nothing.
Thanks in advance


Comment created by @beberlei:

Fixed formatting


Comment created by @beberlei:

What version of Doctrine are you using? you can check in vendor/doctrine-orm/lib/Doctrine/ORM/Version.php


Comment created by cfyzz:

Thanks, Benjamin, for so quick answer.
I've checked the file you mentioned - the version is "2.1.6"


Comment created by @beberlei:

This was fixed in later versions.


Issue was closed with resolution "Duplicate"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment