小编Mar*_*rco的帖子

"关联是指反面字段"&"映射是否相互矛盾"

我有两个实体,一个用于预订,另一个用于可以预订的桌子.此实体具有ManyToMany关系.当我尝试验证此架构时,我收到以下错误:

  • 映射Test\TestBundle\Entity\Table#reservations和
    Test\TestBundle\Entity\Reservation#tables彼此不一致.
  • 关联Test\TestBundle\Entity\Reservation#tables
    指的是不存在的反面字段Test\TestBundle\Entity\Table#tables.

我能帮忙解决这个问题吗?我无法弄清楚我做错了什么.

表实体:

/**
*
* @ORM\Entity
* @ORM\Table(name="tables")
* @ORM\Entity(repositoryClass="Test\TestBundle\Repository\TableRepository")
*/
class Table {    
 /**
 * @var integer $id
 * @ORM\ID
 * @ORM\Column(name="id", type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @ORM\Column(type="integer", length=3)
 */
protected $nmbr;

/**
 * @ORM\ManyToMany(targetEntity="Reservation", mappedBy="tables", cascade={"persist"})
 */
private $reservations;


public function addReservation($reservation) {
    $reservation->addTable($this);
    $this->reservations[] = $reservation;
}



public function getId() {
    return $this->id;
}

public function getNmbr() {
    return $this->nmbr;
}

public function getReservations() {
    return $this->reservations;
}

public …
Run Code Online (Sandbox Code Playgroud)

mapping orm symfony doctrine-orm

4
推荐指数
1
解决办法
4952
查看次数

标签 统计

doctrine-orm ×1

mapping ×1

orm ×1

symfony ×1