簡體   English   中英

參數無值-Hibernate JPA

[英]no value for parameter - hibernate jpa

我有這個查詢

Query query = entityManager.createQuery("SELECT m FROM MenuEntity m WHERE m.idParent = 0 AND m.menuProfiles IN :profile ")
                .setParameter("profile",menuProfileEntitySet);

@OneToMany(fetch = FetchType.LAZY, mappedBy = "menu")
    public Set<MenuProfileEntity> getMenuProfiles() {
    return this.menuProfiles;
}

menuProfileEntitySet是一組MenuProfileEntity查詢,失敗,主題主題中存在錯誤

您的查詢無效。 您可以測試單個菜單配置文件是否在一個集合中,但是不能測試整套菜單配置文件是否在另一個集合中。 您需要加入:

select distinct m from MenuEntity m 
join m.menuProfiles profile
where m.idParent = 0 and profile in :profiles 

這將返回所有idParent等於0並且在給定的配置文件集中具有至少一個配置文件的菜單實體。

暫無
暫無

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

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