diff --git a/src/Repository/DynamoDBRepository.php b/src/Repository/DynamoDBRepository.php index b8747c5..a78c338 100644 --- a/src/Repository/DynamoDBRepository.php +++ b/src/Repository/DynamoDBRepository.php @@ -291,7 +291,15 @@ public function getOneById( ); } - return $this->hydrator->hydrate($this->marshaler->unmarshalItem($output[0])); + $result = $this->hydrator->hydrate($this->marshaler->unmarshalItem($output[0])); + + if ((is_object($result)) && (method_exists($result, 'hasExpired')) && ($result->hasExpired())) { + throw new EntityNotFoundException( + sprintf('%s by ID %s has expired', $this->modelClassName, $id) + ); + } + + return $result; } /**