How do I use the current date in an HQL query with an Oracle database? How do I use the current date in an HQL query with an Oracle database? oracle oracle

How do I use the current date in an HQL query with an Oracle database?


Shouldn't it be current_date?

Hibernate will translate it to the proper dialect.

I did not find a real "Hibernate will translate this to that" reference documentation, but the expression, in general, can be found in HQL Expressions for Hibernate 4.3.

Then there is the Java Persistence API 2.0 (JPA) specification which defines expressions for the Java Persistence query language (JPQL) and their meaning e.g. for current_date:

4.6.17.2.3 Datetime Functions functions_returning_datetime:= CURRENT_DATE | CURRENT_TIME | CURRENT_TIMESTAMP The datetime functions return the value of current date, time, and timestamp on the database server.


Is current_date() a Hibernate function?

I would use sysdate instead. like this:

where alert.expiration > sysdate 

Or to ignore time of day:

where alert.expiration > trunc(sysdate)