簡體   English   中英

通過關鍵字查找查詢時如何在Spring JPA中使用order by

[英]How to use order by in spring jpa when the query is to find by keyword

我有一個看起來像這樣的查詢,

@Query("select p from Product p where p.title like concat ('%',?1,'%') and p.categoryId = ?2")

我如何使用訂單? 我嘗試遵循它給了我語法異常

@Query("select p from Product p where p.title like concat ('%',?1,'%') and p.categoryId = ?2" order by createddate desc)

在此先感謝您的幫助。

如果createddate是“產品”字段,請嘗試:

@Query("select p from Product p where p.title like concat ('%',?1,'%') and p.categoryId = ?2 order by p.createddate desc")

顯示異常。IMO,您的拼寫錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM