1
類似this post,我有這些(幾乎相同)類:JPA查詢與@ManyToMany關係,並沒有導航
public class Project {
@ManyToMany
private Set<Person> resources;
// get and set of resources
}
public class Person {
}
不同的是,我的屬性是私有的(用豆實體)。
問題是:我將如何創建一個查詢來返回確定人員的所有項目(在JPQL和/或使用CriteriaQuery)?
我發現所有這些其他類似的問題,但沒有幫助我,是因爲它們都依賴於導航從Project
到Person
(其中不存在從Person
查詢):
- JPQL ManyToMany select
- @ManyToMany JPA 2 complex query
- JPA 2.0 CriteriaQuery on tables in @ManyToMany relationship
我不喜歡插入'Person'中的一個屬性只是爲了能夠進行查詢,因爲它在我的模型中沒有意義。
謝謝!
它工作。謝謝! –