您好我有下面的類學說2級聯= {「」去掉「}似乎並不奏效
/**
* MP\User\RegistrationBundle\Entity
*/
namespace MP\User\RegistrationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Persistence\PersistentObject;
use MP\Services\SiteAdapterBundle\Util\String;
/**
* @ORM\Table(name="customer")
* @ORM\Entity(repositoryClass="MP\User\RegistrationBundle\Repositories\CustomerRepository")
* @ORM\HasLifecycleCallbacks
*/
class Customer extends PersistentObject
{
/**
* @var string $id
* @ORM\Id
* @ORM\Column(name="icustomer_id", type="integer")
*/
protected $id;
/**
* @var string $addresses
* @ORM\OneToMany(targetEntity="MP\User\RegistrationBundle\Entity\Address", mappedBy="customer", cascade={"remove"})
*/
protected $addresses;
以下關係
/**
* MP\User\RegistrationBundle\Entity
*/
namespace MP\User\RegistrationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Persistence\PersistentObject;
/**
* @ORM\Table(name="custdeladd")
* @ORM\Entity(repositoryClass="MP\User\RegistrationBundle\Repositories\AddressRepository")
*/
class Address extends PersistentObject
{
/**
* @var integer $suffix
* @ORM\Column(name="isuffix", type="integer")
* @ORM\Id
*/
protected $suffix;
/**
* @var object $customer
* @ORM\ManyToOne(targetEntity="MP\User\RegistrationBundle\Entity\Customer", inversedBy="addresses", cascade={"persist"})
* @ORM\JoinColumn(name="icustomer_id", referencedColumnName="icustomer_id")
*/
protected $customer;
}
有誰知道爲什麼當客戶被刪除的地址不是?非常感謝
cascade = {「remove」}爲我工作 – jmoz