2

CommonResource我想在映射的超类和实体之间建立多对多的关联Author。我们正在使用学说手册提供的关于这个主题的语法:关联覆盖学说。但是当我用我验证学说模式时,php bin/console doctrine:schema:val我得到以下错误:

[Mapping]  FAIL - The entity-class 'AppBundle\Entity\Author' mapping is invalid:
* The association AppBundle\Entity\Author#entities refers to the owning side field AppBundle\Entity\CommonResource#authors which does not exist.

我有一个映射的超类CommonResource

/**
 * Class CommonResource
 * @ORM\MappedSuperclass()
 * @ORM\HasLifecycleCallbacks
 */
class CommonResource
{
...
/**
     * @var
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Author", inversedBy="entities")
     */
    protected $authors;
}

和一个实体Author

/**
 * Author
 *
 * @ORM\Table(name="author")
 * @ORM\HasLifecycleCallbacks
 */
class Author
{
...
/**
     * @var
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\CommonResource", mappedBy="authors")
     */
    protected $entities;
}

以及一些扩展映射超类的实体,例如:

/**
 * Itinerary
 *
 * @ORM\Table(name="itinerary")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\Itinerary\ItineraryRepository")
 * @ORM\AssociationOverrides({@ORM\AssociationOverride(name="authors", joinTable=@ORM\JoinTable(
 *              name="common_resource_itinerary",
 *              joinColumns=@ORM\JoinColumn(name="common_resource_id"),
 *              inverseJoinColumns=@ORM\JoinColumn(name="itinerary_id")
 *          ))})
 */
class Itinerary extends CommonResource implements AllowedPermissionInterface, EnrollmentInterface, SluggableInterface, CommonResourceEntityInterface
{
...
}

我是否正确使用了映射超类的关联覆盖的学说语法,或者有什么问题?我将不胜感激任何帮助 :)

4

0 回答 0