Skip to content

Instantly share code, notes, and snippets.

@cr0wst
Created November 8, 2021 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cr0wst/7def325b7a05d0b224e0eb22f3f8ea90 to your computer and use it in GitHub Desktop.
Save cr0wst/7def325b7a05d0b224e0eb22f3f8ea90 to your computer and use it in GitHub Desktop.
// Finding a single user using a specification
val filteredUser = userRepository.findOne(specification).orElseThrow { UserNotFoundException() }
// Finding a single user using a specification with nullable
val filteredUser = userRepository.findOneOrNull(specification) ?: throw UserNotFoundException()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment