I am trying to map a relationship between 2 MySQL tables in Doctrine 2. My owning entity is 'Campaign', it joins to 'Channel'.
When a campaign record is saved, it must contain a channel id. When a campaign is retrieved I would like to use this id to join to channel and display the channel name (from the channel table). I believe this is a one-to-one unidirectional relationship, please correct me if I'm wrong.
I have specified the mapping using Doctrine 2 XML as follows:
<one-to-one field="channelId" target-entity="Channel" fetch="EAGER">
<join-column name="channel_id" referenced-column-name="id" />
</one-to-one>
When populating the campaign entity and attempting to persist it, I am getting the following error.
A new entity was found through a relationship that was not configured to cascade persist operations: Mvc\Entity\Channel@0000000034b3dcd500000000cc77faae. Explicitly persist the new entity or configure cascading persist operations on the relationship.
How should this persist be specified, I do not want to modify or save the channel entity. I have studied that Doctrine 2 documentation on 'Association Mapping' but I cannot understand how this is possible.
Thank you.