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

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

报告相同问题?

悬赏问题

  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证