我正在寫一個JPQL查詢,它基於分類集合進行查詢。我的類別可以爲空,因此我正在檢查使用:categories = NULL。當類別爲NULL在JPQL查詢中檢查集合上的NULL?
@Query("Select v from Vendor v join v.org vorg join v.categories cats WHERE vorg.email =:email AND (cats in :categories or :categories = NULL)")
Set<Vendor> filterVendors(@Param("emailId") String emailId, @Param("categories") Set<Category> categories);
以上優良工程。然而,當類別爲多個值出現錯誤
值java.sql.SQLException:操作數應包含1列(S)
而且休眠相關痕跡
category6_.category_id在( ?,? ) 或( ?,? )爲空 )
如何檢查JPQL集合上的空值?我認爲解決這個問題應該可以解決這個錯誤。任何幫助讚賞
謝謝。
1-什麼是vorg.email vorg不是別名。 2-:電子郵件和@參數定義爲名稱「emailId」 – Zeromus
有一個小的錯字。現在糾正它,現在希望很明確。謝謝。 – HopeKing