title: Hibernate: How do I write the HQL for getting records of an entity without records for its identifying relation
body: <p>I have Hibernate Objects defined as </p>
  
  <pre><code>Class SomeText{
    private Long textId;
    private Set&lt;Tag&gt; Tags = new HashSet&lt;Tag&gt;();
  
    @ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE })
    @JoinTable(name = "text_tag_reln",
     joinColumns = { @JoinColumn(name = "textId") },
     inverseJoinColumns = { @JoinColumn(name = "tagId") })
      public Set&lt;Tag&gt; getTags() {
          return Tags;
      }
  }
  
  Class Tag{
    private long tagId;
  }
  </code></pre>
  
  <p>I now want to get all those SomeText objects that do not have any Tags. I wrote the following HQL but it doesn't work.</p>
  
  <pre><code>select st from SomeText as st where st.Tags = null
  </code></pre>
  
  <p>What do I do to get these records. In the SQL world, I would have written a query which would get all distinct textIds from the text_tag_reln table and get all SomeText ids that weren't present in that set. How can I do this in HQL?</p>