title: JPA @ManyToOne, with additional condition
body: <p>I have the following entity:</p>
  
  <pre><code>@Entity
  public class User {
      @ManyToOne
      @JoinColumn(name = "group_code", referencedColumnName = "code")
      private Group group;
  
      public User () {
      }
  
      // ...
  }
  </code></pre>
  
  <p>Is it possible somehow to specify an additional condition for the above join relation? <code>Group</code> is hierarchical and <code>User</code> should always refer to the parent group, so the additional condition would be <code>parent_group == NULL</code>. Note that <code>code</code> itself is not unique.</p>
  
  <p>Here is the group:</p>
  
  <pre><code>@Entity
  public class Group {
      // ...
  
      @ManyToOne
      @JoinColumn(name = "parent_package_code")
      private Group parent;
  
      public Group () {
      }
  
      // ...
  }
  </code></pre>