HQL left join with condition
<p>This may seem basic but it's late and I'm having trouble with the following. </p>

<pre><code>class Group {

  @Id
  String id;
}

class Participation {

  @Id
  String id;

  @ManyToOne
  @JoinColumn(name = "GROUP_ID")
  Group group;

  @ManyToOne
  @JoinColumn(name = "USER_ID")
  User user;
}

class User {

  @Id
  String id;

  @OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  Set&lt;Participation&gt; participations;
}
</code></pre>

<p><a href="http://i.stack.imgur.com/ahnTE.png" rel="nofollow">Class diagram</a></p>

<p>So</p>

<p>Participation -->1 Group</p>

<p>and User 1&lt;-->N Participation</p>

<p>How can I retrieve all Groups with, for a given User, the associated Participation (or null is there is none)? I've been playing with join fetches but to no avail so far...</p>

<p>Many thanks,</p>

<p>CN</p>

<p>PS. I can do this in SQL thus :</p>

<pre><code>select g.d, p.id 
from group as g 
left join participation as p 
on p.group_id = g.id and p.user_id = 2;
</code></pre>