I'm using Doctrine 2. I have an associative entity which points to two entities. Both are part of the composite key.
My problem is that JoinColumn only allows to specify the physical name, not the logical name. I need the two to be different. Everything else can be mapped, so I feel like I missed something.
/**
* @ORM\Entity()
* @ORM\Table(name="user_friend")
*/
class UserFriend
{
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="User", inversedBy="friends")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
**/
private $user;
/**
* @ORM\Id
* @ORM\ManyToOne[...]
**/
private $friend;
private $connectedDate;
}
By the way, I tried separating the relationships from the id columns (user, userId), but that caused problems with cascade persists.
Any solution or perhaps a different route would be appreciated.