I am having trouble with a HQL query. I have a Rules table, a Owner table and a Owner_Rules that holds one to many mapping between owner and their rules (one owner has many rules). The Rules table also has rules that do not have any owners.
I have a rules class, a owner class with one to many mapping for rules (collection).
I would like to write a HQL query that gives me all the rules without any owners.
Something like this pseudo query
where Rule.id not in (select rule.id from Owner as o join Rule as rule)
But it doesn't work. Any help is greatly appreciated.
org.hibernate.QueryException: illegal attempt to dereference collection [Owner.AutoID.Rules] with element property reference [id] [from Rule as rl where rl.id not in (select o.Rules.id from Onwer o)]