I get thees two entities.
This is first which have OneToMany releation:

```
class MarketMain
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="bigint", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\OneToMany(targetEntity="\Acme\CMSBundle\Entity\MarketLanguage", mappedBy="marketMain", indexBy="langId", cascade="all", orphanRemoval=true, fetch="EXTRA_LAZY")
     */
    private $marketLanguage;
}

```

This is second which have reverst ManyToOne releation:

```
class MarketLanguage
{
    /**
     * @var integer
     *
     * @ORM\Column(name="market_id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="NONE")
     */
    private $marketId = 0;

    /**
     * @var integer
     *
     * @ORM\Id
     * @ORM\Column(name="lang_id", type="integer", nullable=false)
     */
    private $langId = 1;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=200, nullable=true)
     */
    private $name;

    /**
     * @var \Acme\CMSBundle\Entity\MarketMain
     *
     * @ORM\ManyToOne(targetEntity="\Acme\CMSBundle\Entity\MarketMain", inversedBy="marketLanguage")
     * @ORM\JoinColumn(name="market_id", referencedColumnName="id")
     */
    private $marketMain;
}

```

And I want to save entity like this:

```
$em = $this->getDoctrine()->getManager();

$marketMain = new MarketMain();
$marketLanguage = new ArrayCollection();
$marketLanguage->set(1,new MarketLanguage());
$marketLanguage->set(2,new MarketLanguage());
$marketLanguage->set(3,new MarketLanguage());
$marketMain->setMarketLanguage($marketLanguage);

foreach ($marketMain->getMarketLanguage() as $market_language)
{
$market_language->setMarketMain($marketMain);
}
$em->persist($marketMain);
$em->flush();

foreach ($marketMain->getMarketLanguage() as $market_language)
{
   $market_language->setName("Default name for MarketMain entity id:".$marketMain->getId());
}
$em->flush();

```

But after second flush my MarketLanguage entities do not updates, in doctrine query log I see that MarketLanguage entities do not have relation after persist with MarketMain. And please do not say that I have to set MarketLanguage names before persist because I have to add flushed ID to that name. 

This is query (from doctrine logs) that executes update in second flush:

```
"START TRANSACTION" [] []
UPDATE market_language SET name = ? WHERE market_id = ? AND lang_id = ? ["Default name for MarketMain entity 15",0,"1"] []
"COMMIT" [] []

```