获取映射错误消息 symfony2
Getting mapping error message symfony2
我有 3 个 table :
事件:
- id
- 事件类型
- 流派事件
- ...
类型事件:
- id
- 类型
- 描述
- ...
类型事件:
- id
- 类型
- 描述
- ...
所以,我想在这 3 个 table 之间建立关系,但我在探查器中收到错误映射消息:
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;
[...]
类型Events.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;
[...]
流派Events.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;
[...]
我可以在 symfony 文档中看到 => 一对多,单向连接 Table
但我不想再table这个简单的关系...
你怎么看?
你犯了一个小错误。在 Events 中你有 private $typeEvents;
而在 TypeEvents 中你有 mappedBy="typesEvents"
,有一个区别 's' 。 GenreEvents 也一样
我有 3 个 table :
事件:
- id
- 事件类型
- 流派事件
- ...
类型事件:
- id
- 类型
- 描述
- ...
类型事件:
- id
- 类型
- 描述
- ...
所以,我想在这 3 个 table 之间建立关系,但我在探查器中收到错误映射消息:
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;
[...]
类型Events.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;
[...]
流派Events.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;
[...]
我可以在 symfony 文档中看到 => 一对多,单向连接 Table 但我不想再table这个简单的关系...
你怎么看?
你犯了一个小错误。在 Events 中你有 private $typeEvents;
而在 TypeEvents 中你有 mappedBy="typesEvents"
,有一个区别 's' 。 GenreEvents 也一样