/**
  * Returns an entity identified by the passed $id. The $id
  * in this case must be of type \Conjoon\Mail\Client\Message\MessageLocation
  * representing the location of the message or the raw id of the data
  * as managed by teh udnerlying data storage..
  *
  * @param \Conjoon\Mail\Client\Message\MessageLocation $id
  *
  * @return \Conjoon\Data\Entity\DataEntity
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function findById($id)
 {
     if (is_object($id)) {
         $data = array('messageLocation' => $id);
         ArgumentCheck::check(array('messageLocation' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Message\\MessageLocation')), $data);
         $id = $id->getUId();
     }
     return parent::findById($id);
 }
 /**
  * Returns an entity identified by the passed $id. The $id
  * in this case must be of type \Conjoon\Mail\Client\Message\AttachmentLocation
  * representing the location of the attachment OR the raw id of the data
  * as managed by the underlying data storage.
  *
  * @param {mixed} $id
  *
  * @return \Conjoon\Data\Entity\DataEntity
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function findById($id)
 {
     if (is_object($id)) {
         $data = array('attachmentLocation' => $id);
         ArgumentCheck::check(array('attachmentLocation' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Message\\AttachmentLocation')), $data);
         $attachmentLocation = $data['attachmentLocation'];
         $key = $attachmentLocation->getIdentifier();
         $messageLocation = $attachmentLocation->getMessageLocation();
         $messageUid = $messageLocation->getUid();
         $query = $this->getEntityManager()->createQuery("SELECT a from Conjoon\\Data\\Entity\\Mail\\DefaultAttachmentEntity a " . "WHERE a.key = :key and a.message = :messageUid");
         $query->setParameter('key', $key);
         $query->setParameter('messageUid', $messageUid);
         try {
             return $query->getSingleResult();
         } catch (\Doctrine\ORM\NoResultException $e) {
             return null;
         }
     }
     return parent::findById($id);
 }