title: Compare two dates with JPA
body: <p>I need to compare two dates in a JPQL query but it doesn't work.</p>
  
  <p>Here is my query:</p>
  
  <pre><code>Query query = em.createQuery(
      "SELECT h 
       FROM PositionHistoric h, 
            SeoDate d 
       WHERE h.primaryKey.siteDb = :site 
       AND h.primaryKey.engineDb = :engine 
       AND h.primaryKey.keywordDb = :keyword 
       AND h.date = d 
       AND d.date &lt;= :date 
       ORDER BY h.date DESC");`
  </code></pre>
  
  <p>My parameter date is a java.util.Date</p>
  
  <p>My query return a objects list but the dates are upper and lower to my parameter.</p>
  
  <p>Someone kown how to do this ?</p>
  
  <p>Thanks.</p>