I've got the following three entities:
@Entity
public class Item {
[...]
@ManyToOne(optional = false)
@JoinColumn(nullable = false)
private ItemDescriptor asset;
[...]
}
@Entity
public class ItemDescriptor {
[...]
@ManyToMany(fetch = FetchType.LAZY)
private Set<ContentPlan> contentPlans;
[...]
}
@Entity
public class Tenant {
[...]
@ManyToMany
private Set<ContentPlan> contentPlans;
[...]
}
Now, I'm looking for a JPA query to give me:
For given Tenant t, get all Items i where i.asset.contentPlans is in t.contentPlans
I've found several realted soultions, but none of them really solved the problem with this setting. Can someone point me to the right direction?
I came up with this:
SELECT i FROM Item i, Tenant t WHERE i.asset.contentPlans IN (t.contentPlans) AND t = :tenant
I guess this should to the job..?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.