Background: A
Pitchcan contain manyVisuals. TheVisuals are stored as a property onPitchin anArrayCollection.
Here's a quick diagram of the Visuals table (visuals), the Pitches table (statuses_pitch) and the join table created by Doctrine as a result.
Schema
Pitch
Here's the relevant mapping information for Pitch. Visual has no mapping back to Pitch because the relationship is unidirectional.
manyToMany:
visuals:
targetEntity: Visual
cascade: ['persist', 'refresh', 'remove']
fetch: EAGER
orphanRemoval: true
joinTable:
name: pitches_visuals
joinColumns:
pitch_id:
referencedColumnName: id
inverseJoinColumns:
visual_id:
referencedColumnName: id
I am making the changes to a Visual in the ArrayCollection of Pitch and then calling $em->persist($pitch) and $em->flush($pitch). The changes to the child Visual are not persisted to the database as I expect.
Before Persisting
Here's what the Pitch object looks like before I persist it. Note that the Visual objects have a visualType property (mapped to visual_type in the db). These are not null when persisting.
After Persisting
Here's the database table after persisting. Note that the visual_type column still has null in there and the change was not persisted.
I have tried
- Through complete laziness thrown cascades all over the place, to no avail
- Changed the cascade refresh from the owning (pitch) to inverse (visual) side
- Looked through the docs to see if cascade refresh is affected specifically in a Many-To-Many relationship - I couldn't find anything concrete on this, or if there *is* a problem, how I would get around it
How can I achieve what I need here, by making a change to


