I'm trying to create a UniqueEntity with 2 fields (both are ManyToOne fields).
The code is as follow:
/*
* @ORM\Table()
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity(fields={"user", "connect"})
*/
class UserConnect
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var boolean $isLeader
*
* @ORM\Column(name="isLeader", type="boolean")
*/
private $isLeader;
/**
* @var date $joinedDate
*
* @ORM\Column(name="joinedDate", type="date")
*/
private $joinedDate;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="userConnects")
*
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Connect", inversedBy="userConnects")
*
*/
private $connect;
The goal is to ensure that I've got only one Entity that link a USER with a CONNECT.
Should I write something else in my @UniqueEntity
declaration?