0

I have these entities

/** @ORM\Entity */ class Produto { /* Other attributes */ /** * @ORM\ManyToOne(targetEntity="Produto\Entity\Categoria") * @ORM\JoinColumn(name="categoria_id", referencedColumnName="id") */ private $categoria; public function getCategoria() { return $this->categoria; } public function setCategoria(Categoria $categoria) { $this->categoria = $categoria; } } 

and

/** @ORM\Entity */ class Categoria { /* Other attributes */ /** @ORM\Column(type="string") */ private $nome; } 

but when I call the method findAll the $categoria attribute category is always null, what am I doing wrong?

I tried adding the OneToMany annotation on the entity categoria, but it did not work well, there is somewhere that explains why this happens? I found nothing in the documentation

1
  • Is the id column included in the other attributes? Commented Sep 18, 2015 at 7:21

1 Answer 1

0

Class Categoria needs to have an $id class variable. Also, the data in the database for Producto entity needs to have the categoria_id field mapped to the Categoria id for this to work.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.