close
nativeQuery = true
如果有使用的話,
就會使用原生 SQL語句去執行,
像你想從資料表去搜尋的話,就可以加這句。
沒有加的話,
就是使用 HQL語句去資料庫去搜尋。
沒有加和是要用資料表做查詢的話,
就會出現錯誤,
org.hibernate.hql.internal.ast.QuerySyntaxException: Prdouct1 is not mapped
範例:
//查詢: 價格(低到高)
@Query(value="select p from Prdouct1 p ORDER BY p.price DESC", nativeQuery = true)
List<ProductBean> findAllProductsByPriceDesc(int price);
全站熱搜