I am using Hibernate and Criteria API to write my database quires. What I need to do is I need two dates difference in days and compare that days with with specific number.
E.g. Commonly written criteria restriction as:
criteria.add(Restrictions.ge("dateProperty1 - dateProperty2", 15));
If you check the documentation of the Restrictions class, you will see that:
But no customized function is available for your case. So what option you have is using the
sqlRestriction, which can be used to express this condition in a native form of your DBMS. That would be a different, but much easier problem, altough clearly not as elegant as your original idea.