I am trying to fetch data according to condition that attribute date1 is 17 minutes later than attribute date2. I can write the code to select based on condition date1 is later than date2 by using:
Restrictions.gtProperty("date1", "date2")
But I didn’t find a good way to add the 17 minutes condition to it. HQL solution is not ideal but is also acceptable if someone knows how to do that.
You can use a
sqlRestriction, which would allow you to directly embed SQL in yourCriteriaquery. You could then use platform-specific SQL to do the comparison. See http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html#querycriteria-narrowing