Search code examples
javajpajpql

jpql date comparison today


I need a jpql query to find all the LoadFileHistory which finishDate be greater than the currente date (since 00:00:00). For instance greater than 27/11/2012 00:00:00.

I already have this one "select o from LoadFileHistory o where o.finishDate = CURRENT_DATE" but gets me nothing.


Solution

  • You should get today's date to the query like detailed here (java.util.Date has the hour, minute, second too...)

    The you should supply it to your query:

    Query q = em.createQuery("select o from LoadFileHistory o where o.finishDate > :today ");
    q.setParameter("today",todaysDateObject,TemporalType.DATE);
    q.getResultList();