title: Handling null values from database in spring jpa
body: <p>This works fine:</p>
  
  <pre><code>@Repository
  public interface VoteDao extends CrudRepository &lt;Vote, Long&gt; {
  
  @Query(value = "select sum(points) from votes where siteuserid= ?1", nativeQuery = true)
  int countBySiteUser(@Param("user") SiteUser user);
  }
  </code></pre>
  
  <p>Except in case when there are no votes yet that the result is NULL and the problem is that I do not know how to handle that case of checking when it is Null since the query does no return anything when I ask...</p>
  
  <pre><code>    System.out.println("!!!!: PROPOSAL VoteService: " + voteDao.countBySiteUser(user));
  </code></pre>
  
  <p>Should it print a Null value for that sysout? The DAO is supposed to answer with a NULL value, but it is not. I would be able to handle that NULL if provided, but it does not.</p>
  
  <p>Thanks in advance for your help!</p>