Hibernate Query unexpected token: INTERVAL

I’m trying to fetch inventories which is opened at last month, for traditional SQL DATE_SUB function should be used here for date calculation. So the HQL is like following

 

But following error appeared when running it in Hibernate QL Query Consonle in Intellij IDEA

 

Unfortunatelly the INTERVAL keyword is not supported in HQL.

 

Solution

An alternative is to calculate the date in Java and pass the result dates to HQL as parameters. The code is like following

 

Implementation code for DateUtil.getLastMonthFirstDay and DateUtil.getLastMonthLastDay