How to obtain CURDATE() / NOW() on a JPA named query?

前端 未结 2 1373
离开以前
离开以前 2021-01-07 18:57

I want to do a select from table where date = TODAY, on mysql that would be where date > CURDATE(), how do I do this on a JPA named query?

相关标签:
2条回答
  • 2021-01-07 19:26

    From the spec:

    4.6.16.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.

    0 讨论(0)
  • 2021-01-07 19:33

    That depends on your JPA provider. Hibernate, for example, supports current_date function:

    from MyEntity where myDateProperty > current_date
    
    0 讨论(0)
提交回复
热议问题