خرید بک لینک

Vote count: 0

I have an entity, "AualReport", which accepts a collection of entities, "AualReportStaffing". An aual report has four different Staffing sections and hence four of these collections (ArrayCollection). Since I can't use a traditional one-to-many relationship, I have to use One-To-Many with Join Table as described here.

So, for example, one of my Staffing collections is defined as such in my AualReport class:

/**
 * @ORMManyToMany(targetEntity="AualReportStaffing", cascade={"persist"}, orphanRemoval=true, fetch="LAZY")
 * @ORMJoinTable(name="aualreports_staffingtenure",
 *      joinColumns={@ORMJoinColumn(name="staffing_id", referencedColumnName="id")},
 *      inverseJoinColumns={@ORMJoinColumn(name="aualreport_id", referencedColumnName="id")},
 *      )
 */
private $staffing;

Now when it comes time to delete an AualReport, Doctrine removes the relationship between the report and the Staffing inside the join table, but it does NOT remove the associated AualReportStaffing entities. I tried adding cascade={"remove"}, but I get a foreign key violation because it is trying to remove the Staffing entity before the join table association is deleted.

What is the best way to remove the orphaned Staffing entities? Obviously orphanRemoval=true is not the answer.

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 14 خرداد 1395 ساعت: 3:14

صفحه بندی