HQL with a collection in the WHERE clause
I've been trying for the this whole a query who is officially giving me nightmares. The system is a user and contact management. So I have UserAccount , Contact and Phone . UserAccount has a bidirectional one-to-many relationship with Contact and an unidirectional one on phone all mapped by a Set : //UserAccount mapping @OneToMany(targetEntity=PhoneImpl.class, cascade= {CascadeType.ALL}) @org.hibernate.annotations.Cascade(value=org.hibernate.annotations.CascadeType.DELETE_ORPHAN) private Set<Phone> phones = new HashSet<Phone>(); @OneToMany(targetEntity=ContactImpl.class, cascade={CascadeType