title: How to avoid INNER JOIN when returning a related entity using a custom constructor in JPQL
body: <p>I have something like this:</p>
  
  <pre><code>@Entity
  public class User implements Serializable {
    ...
    public User(String login, Division division) {
        this.login = login;
        this.division = division;
    }
  
    @ManyToOne
    public Division getDivision() {
        return division;
    }
    ...
  </code></pre>
  
  <p>JQPL:</p>
  
  <p>I'm using a custom constructor here because I don't want the query returning the user's password (and others attributes).</p>
  
  <pre><code>SELECT new com.xyz.app.beans.User(u.login, u.division)
  FROM User u
  WHERE u.login = :login
  </code></pre>
  
  <p>SQL generated:</p>
  
  <pre><code>select
      user0_.login as col_0_0_,
      user0_.division_id as col_1_0_
  from
      dbo.User user0_ 
  inner join
      dbo.Division division1_ 
          on user0_.division_id=division1_.id 
  where
      user0_.login=?
  </code></pre>
  
  <p>Obviously, if Division is null, my query will return an empty list or throw a NoResultException.
  I want the query to return the User regardless if he has a division or not.</p>
  
  <p>There is a way to avoid this?
  How to tell to Hibernate to do a LEFT JOIN instead of an INNER JOIN?</p>