JPQL to view bank date/time with Hibernate without query

Asked

Viewed 979 times

1

There is a way to query the database date/time without using activate query?

On the Oracle I do this:

 SQLQuery qry = session.createSQLQuery("SELECT SYSDATE FROM dual");  

But I would like a general query to not get price to the database.

  • Do you need to use sysdate even? Can’t pick up the date using new Date(), or Calendar.getInstance();? 'Cause then you wouldn’t really be stuck in the bank.

  • Yes friend, I need to try to recover from the data set the date.

1 answer

1

Try this query:

SQLQuery query = session.createSQLQuery("SELECT CURRENT_DATE");
  • Thanks for your attention, but this query is native and works for postgres and maybe for mysql, but not on Oracle. I am looking for a JPQL query instead of a query

  • @Demyscota There actually is this in JPA, but apparently it can only be used in comparisons. See uauHebert’s website.

  • Thank you very much for the comment, for what I saw I will have to settle for the same query Native.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.