I have a setup where I have product feeds, and each feed has many products. The very simplified setup looks something like this:
Feed model:
/**
* Class Feed represents a single feed as supplier by a supplier
* @package App\Model
* @Entity @Table(name="feeds")
*/
class Feed
{
/**
* @var int
* @Id @Column(type="integer") @GeneratedValue
*/
protected $id;
}
Product model:
/**
* Class Product is the base for either supplied and current products
* @package App\Model
*/
class Product
{
/**
* @var int
* @Id @Column(type="integer") @GeneratedValue
*/
protected $id;
/**
* @var Feed
* @ManyToOne(targetEntity="App\Model\Feed", cascade={"remove"})
* @JoinColumn(name="id_feed", referencedColumnName="id", onDelete="CASCADE")
*/
protected $feed;
}
Now as you can see I have cascading enabled, because I want all of the products to be deleted automatically when a feed is deleted.
However... At the moment, when I delete a product, it causes the original feed te be deleted as well. I suspect it has something to do with how the relation is setup, but I can't seem to figure out where it's wrong.
Can anyone show more light on this situation?