title: How to query JPA LocalDateTime field with a LocalDate value?
body: <p>I search for a way to get a list of Objects created on a certain LocalDateTime date saved in the Postgresql database in a field of type TIMESTAMPTZ.</p>
  
  <p>To do so, I tried to use JpaRepository:</p>
  
  <pre><code>List&lt;Object&gt; findByCreationDate(LocalDate date);
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Parameter value [2020-12-12] did not match expected type [java.time.LocalDateTime (n/a)]
  </code></pre>
  
  <p>I also tried writing the query myself with the same result.</p>
  
  <p>The solutions I thought about so far :</p>
  
  <ol>
  <li><p>To get all the objects and filter in Java (but I wouldn't want to go there, so no)</p></li>
  <li><p>To convert the LocalDate parameter in LocalDateTime (but I assume in this case I will see only Objects created at the same exact time, so no. I would consider this option only when I'm sure the fields of time are midnight).</p></li>
  <li><p>To create a method <code>findByCreationDateBetween(LocalDateTime startOfTheDay, LocalDateTime endOfTheDay)</code> (interesting option, but I would like to do the query without modifying the LocalDate and converting it to LocalDateTime at the start and at the end of the day.)</p></li>
  </ol>
  
  <p>I also tried to find some functions that would be able to 'cast' the LocalDateTime in LocalDate in the query or compare the year, the month and the day of the LocalDate and LocalDateTime, but unsuccessfully. The type of creationDate should remain LocalDateTime and the database field of type TIMESTAMPTZ.</p>
  
  <p>Are there any other Jpa @Query alternatives and overall, what would be the best approach for this case ?</p>