How can I use date_sub() function in hql. For Example following in sql query: select * FROM performance where performance_id= 8955 and daterangefrom >= (date_sub('2008-12-01 00:00:00',interval 8 hour));
I have to write this in @NamedQuery, so I tried this but not working:
@NamedQuery(name = "performance.performanceBySourceId", query = "select p from Performance p where p.source.id = :sourceID and p.dateRangeFrom >= (registerFunction('performance.queryString', new SQLFunctionTemplate(Hibernate.STRING, 'date_add('2008-12-01 00:00:00', INTERVAL 2 hour))) order by p.dateRangeFrom desc' ")