【发布时间】:2016-09-15 06:46:59
【问题描述】:
这是我的本机查询(不幸的是我不能使用它,因为本机查询不适用于可分页)
select * from stock_indicators si inner join stock st on si.stock_id = st.id where si.slope_simple_regression_10 > 1 and si.date = (select date from stock_details order by date desc limit 1) order by si.slope_simple_regression_10 desc
这是一个对应的hql查询:
@Query(value = "from StockIndicators si join fetch si.stock where si.slopeSimpleRegression10Days > 1 and si.date = :date order by si.slopeSimpleRegression10Days desc", countQuery = "select count(si.stock) from StockIndicators si where si.slopeSimpleRegression10Days > 1")
Page<StockIndicators> findWithStocksIndicators10DaysTrendUp(Pageable pageable, @Param("date") LocalDate date);
而且这个查询不起作用,出现如下错误:
java.lang.IllegalArgumentException: Parameter with that position [1] did not exist
所以到目前为止我做了什么:
- 改变了参数的顺序(还是一样的错误)
- 将查询更改为包含子查询,但不幸的是 HQL 包含 不支持限制
- 将 date = :date 部分更改为 date = ?2(仍然是同样的错误)
你能帮我解决这个问题吗?
【问题讨论】:
标签: sql spring-data hql