title: Pass date parameter to native query
body: <p>A user can perform actions based on an occurrence value. When this value is equal to 'DAILY', I would like to retrieve all daily actions that have not been completed the last 24 hours.</p>
  
  <p>The working SQL query:</p>
  
  <pre><code>SELECT distinct a.* FROM action as a LEFT OUTER JOIN history as h
  ON a.id = h.action_id
  AND h.user_id= &lt;user&gt; WHERE a.occurrence = 'DAILY' AND (h.id is NULL OR h.entry_date &lt; TIMESTAMP 'yesterday')
  </code></pre>
  
  <p>The equivalent native query:</p>
  
  <pre><code>@Query(value = 
          "SELECT distinct a.* FROM action a "
          + "LEFT OUTER JOIN history h "
          + "ON a.id = h.action_id "
          + "AND h.user_id = :userId "
          + "WHERE a.occurrence='DAILY' AND (h.id IS NULL OR h.entry_date &lt; :yesterday) ", nativeQuery = true)
  public List&lt;Action&gt; findAllAvailableActions(@Param("userId") Long userId, @Param("yesterday") ZonedDateTime yesterday);
  </code></pre>
  
  <p>How it is called in my service :</p>
  
  <pre><code>ZonedDateTime today = ZonedDateTime.now(ZoneOffset.UTC);
  ZonedDateTime yesterday = today.minus(1,ChronoUnit.DAYS);
  Long userId = userDTO.getId();
  List&lt;Action&gt; result = actionRepositoryCustom.findAllAvailableActions(userId, yesterday);
  </code></pre>
  
  <p>However, I do get the wrong results in my tests (actions that have already been completed are returned). I am afraid this is linked to the date parameter. The attribute entry_date is declared as ZoneDateTime in my entity. What am I doing wrong ?</p>
  
  <blockquote>
    <p>hibernate : 5.2.4</p>
  </blockquote>