title: Spring Boot JPA Query for not null
body: <p>I'm using spring boot JPAs and I want to only return values where the status id is not null. What's the best way to query for this?</p>
  
  <p><strong>Domain</strong></p>
  
  <pre><code>@ManyToOne
  @JoinColumn(name = "entity_status_id")
  private entityStatusLookup entityStatusLookup;
  </code></pre>
  
  <p><strong>EntityController</strong></p>
  
  <pre><code>public interface EntityRepository extends CrudRepository&lt;Batch, String&gt; {   
  
      public Page&lt;Entity&gt; findByUploadUserOrderByUploadDateDesc(String userId, Pageable page);
  
      public Entity findByEntityId(String entityId);
  
  }
  </code></pre>
  
  <p><strong>api</strong></p>
  
  <pre><code>@RequestMapping(value="/entity/user", method=RequestMethod.GET)
  public HttpEntity&lt;PagedResources&lt;Entity&gt;&gt; getEntityByUser(Pageable page, PagedResourcesAssembler assembler) {
      String user = SecurityContextHolder.getContext().getAuthentication().getName();
      Page&lt;Enity&gt; entityItems = entityRepository.findByUploadUserOrderByUploadDateDesc(user, page);
  
      return new ResponseEntity&lt;&gt;(assembler.toResource(entityItems), HttpStatus.OK);
  }
  </code></pre>
  
  <p>I realize that I could loop through the returned pages and look for nulls to remove, but I'd rather have the query just return values that are not null. I'm not sure what the best way to query for not null on the entity status id.</p>