2
我目前的Client-Entity有一個卸載區和一個加載區,它們都是ClientArea-Entities。Symfony2/Doctrine2一對多兩次相同的對象
namespace ACME\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sorien\DataGridBundle\Grid\Mapping as GRID;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Common\Collections\ArrayCollection;
/**
* ACME\DemoBundle\Entity\Client
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="ACME\DemoBundle\Entity\ClientRepository")
*/
class Client
{
enter code here/**
* @ORM\OneToMany(targetEntity="ClientArea",mappedBy="client", cascade={"persist", "remove"})
*/
public $unloading_areas;
/**
* @ORM\OneToMany(targetEntity="ClientArea",mappedBy="client", cascade={"persist", "remove"})
*/
public $loading_areas;
}
_
class ClientArea
{
/**
* @ORM\ManyToOne(targetEntity="Client")
*/
public $client;
}
這不起作用,因爲客戶端只能映射1名關聯。 如何正確映射關係?