/**
  * @param object|array $values
  * @return bool
  * @throws \Exception
  */
 public function update($values)
 {
     if (is_object($values)) {
         $values = $this->_hydrator->extract($values);
     }
     $values = array_intersect_key($values, $this->_class->getFields());
     $identifier = $this->_class->getIdentifier();
     $identifiers = array_intersect_key($values, $identifier);
     $result = $this->_em->getConnexionDriver()->updateItem($identifiers, $values, $this->_class);
     if (!$result) {
         throw new \Exception('Something wrong.');
     }
     return $this->_hydrator->hydrate($values, new $this->_entityName());
 }
 /**
  * @param array $values
  * @param ClassMetadata $classMetadata
  * @return array
  */
 protected function getKeyValues(array $values, ClassMetadata $classMetadata)
 {
     return array_map(function ($item) use($values, $classMetadata) {
         if (!isset($values[$item['name']])) {
             throw new MissingIdentifierException('The field `' . $item['name'] . '` is mandatory');
         }
         return [$this->mapTypeField($item['type']) => $values[$item['name']]];
     }, $classMetadata->getIdentifier());
 }