【发布时间】:2017-02-14 12:12:36
【问题描述】:
我的一个存储库中有以下功能:
@RestResource(path = "filter", rel = "filter")
@Query("SELECT t "
+ "FROM Trip t "
+ "WHERE "
+ "(:from IS NULL OR t.startTs >= :from) "
+ "AND (:categories IS NULL OR t.category IN :categories) ")
Page<Trip> filter(
@Param("from") Instant from,
@Param("categories") List<Category> categories,
Pageable pageable);
Category 是一个枚举,存储为:
@Enumerated(EnumType.STRING)
在Trips 表中。
当我使用一个类别执行 HTTP 请求时,我得到了正确的结果。在没有类别键的情况下执行请求时的行为相同。
htt*://localhost/filter?categories=PRIVATE ==> 好的
htt*://localhost/filter ==> 好的
当使用多个类别时:
htt*://localhost/filter?categories=PRIVATE,BUSINESS
我收到以下异常:
org.hibernate.hql.internal.ast.QuerySyntaxException: 意外的 AST 节点:{vector} [select count(t) FROM foo.bar.services.trips.model.Trip t WHERE (:from IS NULL OR t.startTs >= :from) AND (:categories_0_, :categories_1_ 为 NULL 或 t.category IN (:categories_0_, :categories_1_)) ]
有人知道我在这里做错了什么吗?
【问题讨论】:
标签: java spring hibernate jpa spring-data-rest