public function merge($entity) {
    // add to merged
    if (!$this->merged->contains($entity)) {
      $this->merged->add($entity);
    }
    
    // remove from removed,detached
    // nicht remove from persisted
    if ($this->removed->contains($entity)) {
      $this->removed->removeElement($entity);
    }
    if ($this->detached->contains($entity)) {
      $this->detached->removeElement($entity);
    }
    
    if ($this->delegate) {
      return parent::persist($entity);
    }
  }