Details
Description
Dear developers,
I have class defined like this:
/** * @Entity * @HasLifecycleCallbacks */ class Shop_Data_Entity_Customer extends Shop_Data_Entity_Guest { /** * @OneToOne(targetEntity="Shop_Data_Entity_Contact", cascade={"remove"}) * @JoinColumn(name="contact", referencedColumnName="id") */ protected $contact; }
when i run this:
$q = $em->createQuery("select c from Shop_Data_Entity_Customer c");
$q->setMaxResults(1);
$customers = $q->getResult();
$em->remove($customers[0]);
$em->flush();
I get "A detached entity can not be removed".
I don't understand it very well. I need to remove associated entity but it's not done and exception occurs.
I tried it with (like OneToMany)
/**
* @ManyToMany(targetEntity="Shop_Data_Entity_Contact", cascade={"persist","remove"} )
* @JoinTable(name="Shop_Data_Entity_Customer__homes",
* joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )},
* inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )}
* )
*/
public $homes;
and
$q = $em->createQuery("select c from Shop_Data_Entity_Customer c");
$q->setMaxResults(1);
$customers = $q->getResult();
$em->remove($customers[0]->homes[0]);
$em->flush();
worked without problem like this.
orphanRemoval set it's not working so.
Thank for solve and perfect ORM!!! ![]()
Andy
Dear Roman,
When are you going to release 2.0-BETA1 [ 10030 ]? I ask you because i need this patch now to continue my developing.
Thank you very much.
Andy