How can I write HQL for SYSDATE?

I have a condition that checks the current date - 3.

select * from TABLE_1 SYSDATE-3 >= TABLE_1.created_date

How do I write in the Hibernate query language?

+3
source share
2 answers

You need to write HQL using your entities.

http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#queryhql-examples

There are several examples that use sysdate.

+1
source

For the Oracle SQL dialect, use sysdate(), as in this example:

select e
from Entity e
where (e.endDate is null or (e.endDate > sysdate()))

This is true for orm.xmlor when using<named-query>

For your specific query, "all rows that have not been created in the last three days," use this:

select e from Entity e where to_date(sysdate() - 3) >= e.created_date
+4
source

All Articles