小编Is_*_*sam的帖子

将日期参数传递给本机查询

用户可以根据出现值执行操作。当此值等于“ DAILY”时,我想检索最近24小时内尚未完成的所有日常操作。

有效的SQL查询:

SELECT distinct a.* FROM action as a LEFT OUTER JOIN history as h
ON a.id = h.action_id
AND h.user_id= <user> WHERE a.occurrence = 'DAILY' AND (h.id is NULL OR h.entry_date < TIMESTAMP 'yesterday')
Run Code Online (Sandbox Code Playgroud)

等效的本机查询:

@Query(value = 
        "SELECT distinct a.* FROM action a "
        + "LEFT OUTER JOIN history h "
        + "ON a.id = h.action_id "
        + "AND h.user_id = :userId "
        + "WHERE a.occurrence='DAILY' AND (h.id IS NULL OR h.entry_date < :yesterday) ", nativeQuery = true) …
Run Code Online (Sandbox Code Playgroud)

postgresql spring hibernate jpa

5
推荐指数
1
解决办法
2877
查看次数

标签 统计

hibernate ×1

jpa ×1

postgresql ×1

spring ×1