Is there a way to represent the maximum (and minimum) possible date in JPA without being database specific? The JPA implementation should be then be able to translate it to the correct value according to the used dialect.
If not JPA an Hibernate specific solution would also be OK.
Edit
In an application we are using there are several named queries which test if a date is in a given range
SELECT ... FROM ... WHERE somedate BETWEEN startdate AND end date
If the range is open (only startdate, or only enddate) it would be easier to use the maximum and minimum date that to have different queries with just a single comparison (this would require several changes in the existing application that I would like to avoid).
Edit 2
For the not a real question voters: the question is:
It is possible to query for the maximum possible date in a database agnostic way?
Edit 3
The application is storing dates as java.util.Date as follows
@Temporal( TemporalType.TIMESTAMP )
private java.util.Date someDate;
I believe there is no such feature (yet) to get the max/min date in DB neutral manner.
I’d suggest you to, base on the DBMS you are going to use, define corresponding constants in both Java and DB stored functions.
Therefore you can do something like:
(I used to call that FOREVER and EPOCH 😛 )
or even have HQL like this (if you have create stored function in DB)
from Foo where date between MaxDate() and MinDate()