0 Replies Latest reply on Jun 10, 2008 9:32 AM by Eric H

    QL: select objects where collections overlap

    Eric H Novice

      Ok, here's the Tricky QL Question of the Day.  This can be either EJB3 or Hibernate QL, because of course Hibernate is the delegate in my case.

      I have a table of Tag entities.  Then I have a table of Blog entities.  Each Blog has a set of Tags:

      @Entity public class Blog {
        private Collection<Tag> tags;
        @OneToMany public Collection<Tag> getTags() { return tags; }
      // etc

      If I want to get all the Blog entities which have a certain tag, that's easy:

      select blog from Blog blog where :t member of blog.tags

      But what if I want to find all the Blog entities which have a tag which is a member of a set?  In other words, someone is using a search tool and selects search within blog entities which have tags... and he has checkboxes where he can select several tags?

      Is there a way to say, union of these two sets is not empty?