We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
i made two entities in one-to-one relation and get a "Unknown column" error when i query all rows in the following way
$entityManager->getRepository(Foo::class)->findAll();
Unknown column 't5.id' in 'on clause':
Unknown column 't5.id' in 'on clause'
SELECT t0.id AS id_1, t2.id AS id_3, t2.foo_id AS foo_id_4 FROM foo t0 LEFT JOIN bar t2 ON t2.foo_id = t5.id
This way will work:
$entityManager->getRepository(Foo::class) ->createQueryBuilder('r') ->getQuery() ->getResult();
Entity/Foo.php
<?php namespace App\Entity; use App\Repository\FooRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: FooRepository::class)] class Foo { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\OneToOne(mappedBy: 'foo', cascade: ['persist', 'remove'])] private ?Bar $bar = null; public function getId(): ?int { return $this->id; } public function getBar(): ?Bar { return $this->bar; } public function setBar(Bar $bar): static { // set the owning side of the relation if necessary if ($bar->getFoo() !== $this) { $bar->setFoo($this); } $this->bar = $bar; return $this; } }
Entity/Bar.php
<?php namespace App\Entity; use App\Repository\BarRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: BarRepository::class)] class Bar { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\OneToOne(inversedBy: 'bar', cascade: ['persist', 'remove'])] #[ORM\JoinColumn(nullable: false)] private ?foo $foo = null; public function getId(): ?int { return $this->id; } public function getFoo(): ?foo { return $this->foo; } public function setFoo(foo $foo): static { $this->foo = $foo; return $this; } }
Using doctrine/orm versions: 3.2.1
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
i made two entities in one-to-one relation and get a "Unknown column" error when i query all rows in the following way
Unknown column 't5.id' in 'on clause'
:This way will work:
Entity/Foo.php
Entity/Bar.php
Using doctrine/orm
versions: 3.2.1
The text was updated successfully, but these errors were encountered: