【发布时间】:2018-08-23 14:44:12
【问题描述】:
我正在尝试从这里使用这个查询 - http://technoir.blog/blog/post/timeseries_tips_for_postgresql:
with filled_dates as (
select day, 0 as blank_count from
generate_series('2014-01-01 00:00'::timestamptz, current_date::timestamptz, '1 day')
as day
),
signup_counts as (
select date_trunc('day', created_at) as day, count(*) as signups
from users
group by date_trunc('day', created_at)
)
select filled_dates.day,
coalesce(signup_counts.signups, filled_dates.blank_count) as signups
from filled_dates
left outer join signup_counts on signup_counts.day = filled_dates.day
order by filled_dates.day
当我把它放在@Query("WITH filled_dates as ( .... ") 中时,它会抛出这个错误 -
Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: WITH near line 1, column 1 [WITH filled_dates as
如何在手动 JPA 查询中使用 WITH 子句?
【问题讨论】:
-
您将查阅有关什么是 JPQL 的文档并意识到 SQL != JPQL,并且 Spring 有一些“nativeQuery”标志。但是你已经通过文档了,不是吗?
标签: java postgresql jpa spring-boot