I have some entity, let's say, User, and other entity, Community, with many-to-many relationship between them. The user can be member in one, several or none communities. So, class User has a property communities, of SET type, with all appropriate getters and setters. I want to be able to make select ( by ejbql) for all users that have empty sets of communities, or, alternatively, do have non-empty set. How can I achieve it by ejbql query? On the web side, I have some radio buttons, let's say "Has communities" and "Has no community", and, of cource, I would like to link it to this restriction of ejbql.
Thanks in advance
I don't think this is the right forum for EJBQL questions, but have you tried something like this?
select u from User u where size(u.communities) = 0