symfony 2 : Namespace “Acme” does not contain any mapped entities

后端 未结 7 2326
醉酒成梦
醉酒成梦 2021-02-13 04:23

I am following the book and on the page http://symfony.com/doc/current/book/doctrine.html

While following the book I am trying to work on relationship of product and cat

相关标签:
7条回答
  • 2021-02-13 04:58

    One of the two things may be the problem,

    1. make sure you have a use statement at the top, that is

      use Acme\StoreBundle\Entity\Product;

      It is not included in the example, they only displayed use Doctrine\Common\Collections\ArrayCollection;

    2. When specifying target entity always specify full namespace if the entities are in different name spaces. example:

      @ORM\OneToMany(targetEntity="Acme\StoreBundle\Entity\Product", mappedBy="category")

      instead of:

      @ORM\OneToMany(targetEntity="Product", mappedBy="category")

      The second one only works if the two entities are in same namespace and that entity has been called by use statement above the class.

    0 讨论(0)
提交回复
热议问题