title: Doctrine OneToOne remove entity
body: <p>When I remove entity, relations OneToOne has not been removed. Gallery has been removed successfully from database, but largeImage, mediumImage and smallImage not. </p>
  
  <p>What I do wrong?</p>
  
  <p>Delete action in controller:</p>
  
  <pre><code>public function deleteAction($id)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $offer = $em-&gt;getRepository('ToCmsBundle:Offer')-&gt;find($id);
  
      if($offer) {
  
          if(!$offer-&gt;getGallery()-&gt;isEmpty()) {
              foreach($offer-&gt;getGallery() as $key =&gt; $image) {
                  $image-&gt;setOffer(null);
                  $offer-&gt;removeGallery($image);
                  //$em-&gt;remove($image);
                  //$em-&gt;flush();
                  echo $image-&gt;getPath() . '&lt;br/&gt;';
              }
          } else {
              echo 'gallery is empty';
          }
  
          $offer-&gt;setLargeImage(null);
          $offer-&gt;setMediumImage(null);
          $offer-&gt;setSmallImage(null);
  
          $em-&gt;remove($offer);
  
          $em-&gt;flush();
      }
  
      return $this-&gt;redirect($this-&gt;generateUrl('to_offer_list'));
  }
  </code></pre>
  
  <p>My owner class:</p>
  
  <pre><code>/**
   * Offer
   *
   * @ORM\Table(name="to_offer")
   * @ORM\HasLifecycleCallbacks
   * @ORM\Entity(repositoryClass="To\CmsBundle\Repository\OfferRepository")
   */
  class Offer {
  
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="title", type="string", length=255)
       */
      private $title;
  
      /**
       * @var string
       *
       * @ORM\Column(name="content", type="text")
       */
      private $content;
  
      /**
       * @var ArrayCollection
       * 
       * @ORM\OneToMany(targetEntity="Image", mappedBy="offer", cascade={"all"}, orphanRemoval=true)
       */
      private $gallery;
  
      /**
       * @var Image
       * 
       * @ORM\OneToOne(targetEntity="Image", cascade={"all"}, orphanRemoval=true)
       */
      public $largeImage;
  
      /**
       * @var Image
       * 
       * @ORM\OneToOne(targetEntity="Image", cascade={"all"}, orphanRemoval=true)
       */
      public $mediumImage;
  
      /**
       * @var Image
       * 
       * @ORM\OneToOne(targetEntity="Image", cascade={"all"}, orphanRemoval=true)
       */
      public $smallImage;
  
      /**
       * @var ArrayCollection
       * 
       * @ORM\ManyToMany(targetEntity="Category", inversedBy="articles")
       * @ORM\JoinTable(name="to_articles_categories")
       */
      private $categories;
  
      /**
       * @var User
       * 
       * @ORM\ManyToOne(targetEntity="User")
       * @ORM\JoinColumn(name="author_id", referencedColumnName="id")
       */
      private $author;
  
      public function __construct() {
          $this-&gt;gallery = new ArrayCollection();
          $this-&gt;categories = new ArrayCollection();
      }
  
      /** other stuff */
  }
  </code></pre>
  
  <p>Image class:</p>
  
  <pre><code>/**
   * Image
   *
   * @ORM\Table(name="to_images")
   * @ORM\Entity(repositoryClass="To\CmsBundle\Repository\ImageRepository")
   * @ORM\HasLifecycleCallbacks
   */
  class Image
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       */
      private $name;
  
      /**
       * @var string
       *
       * @ORM\Column(name="hashName", type="string", length=255)
       */
      private $hashName;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="position", type="integer")
       */
      private $position;
  
      /**
       * @var string
       *
       * @ORM\Column(name="path", type="string", length=255)
       */
      private $path;
  
      /**
       * @var string
       *
       * @ORM\Column(name="thumbnail", type="string", length=255)
       */
      private $thumbnail;
  
      /**
       * @var string
       *
       * @ORM\Column(name="originalImage", type="string", length=255)
       */
      private $originalImage;
  
      /**
       * @var Offer
       * 
       * @ORM\ManyToOne(targetEntity="Offer", inversedBy="gallery")
       * @ORM\JoinColumn(name="offer_id", referencedColumnName="id", nullable=true)
       */
      private $offer;
  
      /**
       * @var \DateTime
       *
       * @Gedmo\Timestampable(on="create")
       * @ORM\Column(name="createdAt", type="datetime")
       */
      private $createdAt;
  
      /**
       * @var \DateTime
       *
       * @Gedmo\Timestampable(on="update")
       * @ORM\Column(name="updatedAt", type="datetime")
       */
      private $updatedAt;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="x", type="integer")
       */
      protected $x = 0;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="y", type="integer")
       */
      protected $y = 0;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="w", type="integer")
       */
      protected $w = 0;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="h", type="integer")
       */
      protected $h = 0;
  
      /**
       * @var boolean
       * 
       * @ORM\Column(name="defaultImage", type="boolean")
       */
      private $default = 0;
  
  
      public function __construct() {
          $this-&gt;position = 0;
          $this-&gt;default = 0;
          $this-&gt;x = 0;
          $this-&gt;y = 0;
      }
      /**
       * @ORM\PrePersist()
       * @ORM\PreUpdate()
       */
      public function preUpload()
      {
          $this-&gt;position = $this-&gt;position ?: 0;
          $this-&gt;default = $this-&gt;default ?: 0;
          $this-&gt;x = $this-&gt;x ?: 0;
          $this-&gt;y = $this-&gt;y ?: 0;
  
          /*if (null !== $this-&gt;getFile()) {
              // do whatever you want to generate a unique name
              $this-&gt;name = sha1(uniqid(mt_rand(), true));
              $this-&gt;originName = $this-&gt;getFile()-&gt;getClientOriginalName();
              $this-&gt;extension = $this-&gt;getFile()-&gt;guessExtension();
  
              $this-&gt;path = $this-&gt;name.'.'.$this-&gt;extension;
          }*/
      }
  
      /**
       * @ORM\PreRemove()
       */
      public function removeUpload()
      {
  
          echo $this-&gt;getRootPath().$this-&gt;originalImage; echo '&lt;br/&gt;';
          echo $this-&gt;getRootPath().$this-&gt;thumbnail; echo '&lt;br/&gt;';
          echo $this-&gt;getRootPath().$this-&gt;path; echo '&lt;br/&gt;';
          echo '&lt;br/&gt;&lt;br/&gt;';
  
          if(file_exists($this-&gt;getRootPath().$this-&gt;originalImage))
              unlink($this-&gt;getRootPath().$this-&gt;originalImage);
          if(file_exists($this-&gt;getRootPath().$this-&gt;thumbnail))
              unlink($this-&gt;getRootPath().$this-&gt;thumbnail);
          if(file_exists($this-&gt;getRootPath().$this-&gt;path))
              unlink($this-&gt;getRootPath().$this-&gt;path);
      }
      /** other stuff */
  }
  </code></pre>