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

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

报告相同问题?

悬赏问题

  • ¥20 如何推断此服务器配置
  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 找一个QT页面+目标识别(行人检测)的开源项目
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败