簡體   English   中英

JPA 本機查詢問題說沒有找到類型的屬性

[英]Issue with JPA native queries saying No property found for type

我有一個使用 JPA 本機查詢的 spring 啟動應用程序。 這些查詢位於單獨的屬性文件中。 我有 3 個查詢,分別稱為 getSomething、getSomethingWithSomeParam 和 getSomethingWithOtherParam。 當它只是 getSomething 時,端點工作正常。 當我添加 getSomethingWithSomeParam 端點/查詢時,它也按預期工作。

但是,當我添加 getSomethingWithOtherParam 時,JPA 開始拋出此錯誤:

IllegalArgumentException: Failed to create query for method ... DataAccessLayer.getSomethingWithOtherParam(...)! No Property getSomething found for type DTO!

這是數據訪問層的樣子:

@Query(nativeQuery = true)
public List<String> getSomething();

@Query(nativeQuery = true)
public List<String> getSomethingWithSomeParam(@Param("some") String some);

@Query(nativeQuery = true)
public List<String> getSomethingWithOtherParam(@Param("other") String other);

如果參數數量和類型相同,JPA 是否不允許具有相似名稱的多個查詢? 為什么 JPA 在哪個查詢到 map 的每個查詢方法中變得混亂?

我認為你的代碼沒有問題,因為我已經多次使用這種方法。 因為方法是從另一層靜態調用的,所以在代碼中定義方法和參數沒有問題。 您可能設置了導致錯誤的服務器端設置。 為此,您可以創建一個簡單的項目來測試它。

暫無
暫無

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

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