[jpa] Is it possible to execute query using calculated restrictions?
Is it possible to use calculated restrictions, e.g. using Specifications, in a JPA query?
Take for example this domain class
class Machine {
private boolean currentlyInMaintenance;
private Date lastMaintenanceDate;
private int months; // number of months new maintenance is needed
}
And the query I want to execute is:
Select all machines where
a) currentlyInMaintenance is false
b) lastMaintenanceDate + months is after current date
Any ideas?
I know e.g. Hibernate has a @Formula annotation but I don't know if standard JPA supports something like this.
Cheers,
Marcel