title: Check date between two dates with spring data jpa and mysql
body: <p>I need select date between two values in spring data jpa.</p>
  
  <pre><code>   SELECT * FROM Device WHERE create_date &gt;='2019-08-16' and 
     create_date &lt;='2019-08-17';
  </code></pre>
  
  <p>I have this model :</p>
  
  <pre><code>  CREATE TABLE `device` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `create_date` date DEFAULT NULL
  
     @Entity
     public class Device implements Serializable {
  
     private java.sql.Date createDate;
     }
  </code></pre>
  
  <p>I tried many variants.</p>
  
  <pre><code>  public interface DeviceRepository extends JpaRepository&lt;Device, Long&gt; {
  
  
    List&lt;Device&gt;getDevicesByCreateDateIsGreaterThanEqual
    AndCreateDateIsLessThanEqual(Date from, Date to);
  
    public final static String FIND_BY_CREATE_DATE =
    "SELECT a FROM Device a " +"WHERE a.createDate BETWEEN :x AND :y";
  
    @Query(FIND_BY_CREATE_DATE)
    List&lt;Device&gt; getXY(@Param("x") Date x, @Param("y") Date y);
  
    @Query("select a from Device a where a.createDate &gt;= :date1 and 
    a.createDate &lt;= :date2")
  
    List&lt;Device&gt; findAllWithCreationDateBetween2(
    @Param("date1") Date date1, @Param("date2") Date date2);
  
    @Query("SELECT a FROM Device a WHERE a.createDate &gt;= ?1 
    AND a.createDate &lt;= ?2")
  
    List&lt;Device&gt; findAllWithCreationDateBetween(Date from, Date to);
  
    @Query("SELECT a FROM Device a WHERE a.createDate &gt;= ?1 
    AND a.createDate &lt; ?2")
    List&lt;Device&gt; findAllWithCreationDateBetween(Date from, Date to);
  </code></pre>
  
  <p>If I have in MySQL database java.sql.Date in format 2019-08-17. 
  If I select from 2019-08-16 to 2019-08-18 it works perflectly. 
  If I select from 2019-08-17 to 2019-08-18 it works perflectly.</p>
  
  <p>If I select from 2019-08-16 to 2019-08-17 no result return. 
  If I select from 2019-08-17 to 2019-08-17 no result return.</p>
  
  <p>Thank you very much.</p>