openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Broadhead <matthew.broadh...@nbmlaw.co.uk>
Subject criteriabuilder mysql date_sub function
Date Sun, 14 Jan 2018 17:45:56 GMT
TomEE 7.0.3 (OpenJPA 2.4.2)
I am trying to write the following statement using CriteriaBuilder:
select t0.* from my_table as t0 where date(now()) between 
date_sub(t0.customdate, INTERVAL t0.reminder DAY) and t0.customdate
I thought it might look something like this:
CriteriaBuilder cb = em.getCriteriaBuilder();
cb.between(new Date(), cb.function("date_sub", Date.class, 
myTable.get(MyTable_.customdate), myTable.get(MyTable_.customdate)), 
myTable.get(MyTable_.customdate))
But I can't work out how to finish it

Mime
View raw message