我試圖根據用戶的搜索請求顯示一組數據庫中的記錄。我不認爲在JPA存儲庫中有一個預定義的方法。因此,我想在此存儲庫中編寫一個查詢。如何在Jpa庫中編寫一個Sql查詢?
但在構建過程中,有一個異常聲明爲「IllegalArgumentException」。
有人可以幫我寫一個正確的查詢嗎?如果有更好的方法,讓我知道。
在論證的loanReport是具有用戶的搜索請求
public interface LoanReportRepository extends JpaRepository<LoanReport, Long> , JpaSpecificationExecutor<LoanReport> {
public final static String GET_LOAN_REPORTS = "SELECT * FROM loan_report WHERE product=loanReport.product";
@Query(GET_LOAN_REPORTS)
List<LoanReport> findByPreference(final LoanReport loanReport);
}
這不是JPQL。閱讀任何JPA文檔以查看該文檔。如果你真的想把SQL放入(並丟棄數據庫獨立性),Spring會有一些「原生」標誌。 –