title: How to properly handle empty resultset with Hibernate and Spring Boot
body: <p>I have a Spring app that is using Hibernate and the Spring Data JPA's <code>CrudRepository</code>. Everything seems to work properly if the data that was queried for exists in the database. However, if there is a query that returns no result, the <code>CrudRepository</code> returns <code>null</code> and I get a <code>NullPointerException</code>. So for example <code>http://localhost:8080/api/id=3</code> if there is a row with id 3 in the database it works fine. If there isn't a row with id of 3 it fails with a:</p>
  
  <blockquote>
    <p>there was an unexpected error (type=Internal Server Error,
    status=500)</p>
  </blockquote>
  
  <p>On the client side and a <code>NullPointerException</code> on the server side.</p>
  
  <p>What is the proper way of dealing with a simple case of a "No Results" query?</p>