title: Spring CrudRepository .orElseThrow()
body: <p>What is the proper way to throw an exception if a database query returns empty? I'm trying to use the <code>.orElseThrow()</code> method but it won't compile :</p>
  
  <pre><code>Meeting meeting = meetingRepository.findByMeetingId(meetingId).orElseThrow(new MeetingDoesNotExistException(meetingId));
  </code></pre>
  
  <p>The compiler is saying : </p>
  
  <blockquote>
    <p>"he method orElseThrow(Supplier) in the type Optional is not applicable for the arguments (MeetingRestController.MeetingDoesNotExistException)</p>
  </blockquote>
  
  <p>Is it possible to do this with lambda expressions?</p>
  
  <p>CrudRepository : </p>
  
  <pre><code>import java.util.Optional;
  
  import org.springframework.data.repository.CrudRepository;
  
  public interface MeetingRepository extends CrudRepository&lt;Meeting, Long&gt;{
      Optional&lt;Meeting&gt; findByMeetingId(Long id);
  }
  </code></pre>
  
  <p>Exception :</p>
  
  <pre><code>@ResponseStatus(HttpStatus.CONFLICT) // 409
  class MeetingDoesNotExistException extends RuntimeException{
    public MeetingDoesNotExistException(long meetingId){
      super("Meeting " + meetingId + " does not exist.");
    }
  }
  </code></pre>