SQLGrammarException: 无法提取结果集
SQLGrammarException: could not extract ResultSet
我想执行以下查询:
@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
如何在此查询中选择 desc
或 ac
?
有一种方法可以将 Pageable
用于本机查询。 Spring 如果 Pageable
.
中有 Sort
对象,数据将附加到您的请求“order by”的末尾
List<WashHistory> findDesc(Integer carWashId,String descOrAsc, Pageable pageable);
我想执行以下查询:
@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
如何在此查询中选择 desc
或 ac
?
有一种方法可以将 Pageable
用于本机查询。 Spring 如果 Pageable
.
Sort
对象,数据将附加到您的请求“order by”的末尾
List<WashHistory> findDesc(Integer carWashId,String descOrAsc, Pageable pageable);