title: Querying associate table with HQL
body: <p>I have two Entity class with a oneToMany relationship:</p>
  
  <pre><code>@Entity
  @XmlRootElement
  @DynamicInsert (value = true)
  @DynamicUpdate (value = true)
  public class Matchs {
  
     @Id @GeneratedValue
     private Long matchId;
     private int size;
  
     @OneToMany(fetch = FetchType.LAZY)
     @JoinTable(name = "Match_Users",joinColumns=@JoinColumn(name="match_id"),
     inverseJoinColumns=@JoinColumn(name="user_id"))
     private List&lt;User&gt; users;
  
        //Getters &amp; Setters
  }
  
  @Entity
  @XmlRootElement
  @DynamicInsert (value = true)
  @DynamicUpdate (value = true)
  public class User {
  
      @Id
      private String username;
      private String lastName,firstName,password,email;
  
      private Date dateOfBirth;
          //Getters &amp; Setters
    }
  </code></pre>
  
  <p>I want to get all Matchs for a particular User.This is my query:</p>
  
  <pre><code> FROM Matchs WHERE User.username=:username 
  </code></pre>
  
  <p>This query throws org.hibernate.QueryException. How can I accomplish this with HQL.</p>