title: HQL JOIN involving multiple associations
body: <p>I have three entities with relation <code>UserDetails</code> hasmany <code>FiledTask</code> and <code>Task</code> hasMany <code>FiledTask</code>. All I want is list of <code>FiledTask</code> of particular <code>User</code></p>
  
  <p>For UserDetails:</p>
  
  <pre><code>@OneToMany(mappedBy="user",cascade=CascadeType.ALL)
  Collection&lt;FiledTask&gt; filedTasks = new ArrayList&lt;FiledTask&gt;();
  </code></pre>
  
  <p>And for Tasks I have </p>
  
  <pre><code>@OneToMany(mappedBy="task")
  Collection&lt;FiledTask&gt; filedTasks = new ArrayList&lt;FiledTask&gt;();
  </code></pre>
  
  <p>And FiledTask looks like </p>
  
  <pre><code>@ManyToOne
  @JoinColumn(nullable = false, name = "taskId")
  private Tasks task;
  @ManyToOne
  @JoinColumn(nullable = false, name = "userId")
  private UserDetails user;
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>query = session.createQuery("from Tasks as tasks inner join tasks.filedTasks as files with files.user = :user");
  query.setParameter("user", user); //user is UserDetails instance
  </code></pre>
  
  <p>But I am getting error clause can only reference columns in the driving table, means FiledTask can't userId for comparision?</p>
  
  <pre><code>with clause can only reference columns in the driving table [from com.akhi.app.cdm.Tasks as tasks inner join tasks.filedTasks as files with files.user = :user]
  </code></pre>