I have an entity with a timestamp field, but for the purpose of a certain query, I want to only compare by date - and ignore the time component of the value.

For example, in Oracle, the raw SQL would look like:

SELECT t0.BASE_DATA_ID, t0.CLIENT_ID, t0.DB_USER, t0.OS_USER, t0.UPSERT_DATE,
       t0.CRNCY_CODE, t0.datadate, t0.ident, t0.LAST_PUBLISHED_DATE,
       t0.PRICE_VAL_1, t0.PRICE_VAL_2, t0.TYPE_NAME
       FROM MD_BASE_DATA t0
       WHERE (t0.CLIENT_ID = 'JUNIT-1'
       and to_date(to_char(t0.UPSERT_DATE,'YYYY-MM-DD'),'YYYY-MM-DD')
       = to_date(to_char(current_date - 1,'YYYY-MM-DD'),'YYYY-MM-DD'))

This query filters by field "UPSERT_DATE" being yesterday, ignoring the time part.

How can I do this in JPA?

Thanks,


Chris

Reply via email to