title: Hibernate: Criteria with many-to-many join table?
body: <p>Consider following two relations:</p>
  
  <pre><code>@Entity class Foo {
      @Id id;
  
      @ManyToMany
      @JoinTable(name = "ATag", 
           joinColumns = @JoinColumn(name = "foo_id"),
           inverseJoinColumns = @JoinColumn(name = "tag_id"))
      Set&lt;Tag&gt; tags;
  }
  
  @Entity class Tag {
      @Id Long id;
      String name;
  }
  </code></pre>
  
  <p>There is no corresponding entity class for the join table ATag. Now, I want to get all Foo instances with Tag named 'tag1', is it possible using only Criteria?</p>
  
  <p>A sub-query maybe helpful, however, I can't create DetachedCriteria for class ATag.class which isn't existed.</p>