У меня есть две модели, которые связаны друг с другом:
/** @Entity @Table(name="permissions") */
class Permissions {
/**
* @Id @GeneratedValue @Column(type="integer")
* @var integer
*/
protected $id;
/**
* @Column(type="string")
* @var string
*/
protected $name;
public function getId() { return $this->id; }
public function setName($name) { $this->name = $name; }
public function getName() { return $this->name; }
}
и
/** @Entity @Table(name="permissions_types") */
class PermissionsTypes {
/**
* @Id
* @OneToOne(targetEntity="Permissions")
* @JoinColumn(name="perm_id", referencedColumnName="id")
*/
protected $perm;
/**
* @Id
* @Column(type="integer")
* @var string
*/
protected $type;
/**
* @Column(type="string")
* @var string
*/
protected $name;
public function setType($type) { $this->type = $type; }
public function getType() { return $this->type; }
public function setName($name) { $this->name = $name; }
public function getName() { return $this->name; }
}
Когда я хочу добавить в PermissionsTypes две сущности со значениями:
perm | type | name
-------------------
1 | 0 | test1
1 | 1 | test2
Я получаю
Дублирующаяся запись '1' для ключа 'UNIQ_12CF91AFFA6311EF'
ошибка в 1-м столбце. Что я делаю не так?