How to query JPA LocalDateTime field with a LocalDate value?

后端 未结 3 595
名媛妹妹
名媛妹妹 2021-01-21 00:12

I search for a way to get a list of Objects created on a certain LocalDateTime date saved in the Postgresql database in a field of type TIMESTAMPTZ.

To do so, I tried to

3条回答
  •  执笔经年
    2021-01-21 00:27

    Your current solution is fine. But in @Query you can cast column using DATE()

    @Query(value = "SELECT * FROM Entity u WHERE DATE(creation_date) = ?1", nativeQuery = true)
    List findByCreationDate(LocalDate date);
    

提交回复
热议问题