douyu0792 2016-03-31 09:38
浏览 45
已采纳

获取映射错误消息symfony2

I have 3 table :

Events:

  • id
  • typeEvents
  • genreEvents
  • ...

TypeEvents:

  • id
  • type
  • description
  • ...

GenreEvents:

  • id
  • genre
  • description
  • ...

So, I want to create a relation-ship between this 3 tables, but i get error mapping message in the profiler:

BISSAP\BenevolesBundle\Entity\Events

The mappings BISSAP\BenevolesBundle\Entity\Events#typeEvents and BISSAP\BenevolesBundle\Entity\TypeEvents#events are inconsistent with each other.
The mappings BISSAP\BenevolesBundle\Entity\Events#genreEvents and BISSAP\BenevolesBundle\Entity\GenreEvents#events are inconsistent with each other.

BISSAP\BenevolesBundle\Entity\TypeEvents

The association BISSAP\BenevolesBundle\Entity\TypeEvents#events refers to the owning side field BISSAP\BenevolesBundle\Entity\Events#typesEvents which does not exist.

BISSAP\BenevolesBundle\Entity\GenreEvents

The association BISSAP\BenevolesBundle\Entity\GenreEvents#events refers to the owning side field BISSAP\BenevolesBundle\Entity\Events#genresEvents which does not exist.

Events.php

class Events
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="TypeEvents", inversedBy="events", cascade={"persist"})
     *
     */
    private $typeEvents;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="GenreEvents", inversedBy="events", cascade={"persist"})
     *
     */
    private $genreEvents;

    /**
     * 
     * @ORM\ManyToOne(targetEntity="BISSAP\UserBundle\Entity\User", inversedBy="events", cascade={"persist"})
     *
     */
    private $user;
    [...]

TypeEvents.php

class TypeEvents
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var ArrayCollection $events
     * @ORM\OneToMany(targetEntity="Events", mappedBy="typesEvents", cascade={"persist", "remove", "merge"})
     */
    private $events;
    [...]

GenreEvents.php

class GenreEvents
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var ArrayCollection $events
     * @ORM\OneToMany(targetEntity="Events", mappedBy="genresEvents", cascade={"persist", "remove", "merge"})
     */
    private $events;
    [...]

I could see in the symfony doc => One-To-Many, Unidirectional with Join Table but I don't want to get an another table to this simple relationship...

what do you think?

  • 写回答

1条回答 默认 最新

  • dongpin3794 2016-03-31 10:12
    关注

    You have a small mistake. in Events you have private $typeEvents;and in TypeEvents you have mappedBy="typesEvents" , there is a difference of 's' . Same for GenreEvents

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗