SQLGrammarException:无法提取ResultSet

时间:2017-06-06 05:18:03

标签: spring spring-boot native

我想执行以下查询:

@Query(value = "select * from wash_history w where w.wash_id IN \n"
        + "(select w.id from wash w where w.car_wash_id=?1) order BY w.time 
?2", nativeQuery = true)
List<WashHistory> findDesc(Integer carWashId,String descOrAsc);

但我有以下错误

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause

如何在此查询中选择descac

1 个答案:

答案 0 :(得分:0)

有一种方法可以将Pageable与原生查询结合使用。 Spring数据将追加到您的请求结束时#34;按顺序排列&#34;如果Sort中有Pageable个对象。

List<WashHistory> findDesc(Integer carWashId,String descOrAsc, Pageable pageable);