title: QueryDSL Null Pointer exception left join unrelated tables
body: <p>I have got two tables which are unrelated . Below are the entity classes .</p>
  <p>UsersStaging</p>
  <pre><code>@Entity
  @Table(name = &quot;users_staging&quot;)
  @Data
  public class Usersstaging implements Serializable{
      private static final long serialVersionUID = 1L;
      
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO, generator = &quot;native&quot;)
      @GenericGenerator(name = &quot;native&quot;, strategy = &quot;native&quot;)
      @Column(name = &quot;id&quot;, updatable = false, nullable = false)
      private Integer id;
      
      @Column(name = &quot;employee_id&quot;, length = 10)
      private String employeeId;
      
      @Column(name=&quot;user_name&quot;)
      private String userName;
      
      @Column(name = &quot;email&quot;)
      private String email;
  </code></pre>
  <p>Roles table</p>
  <pre><code>@Entity
  @Table(name = &quot;user_roles&quot;)
  @Data
  @TypeDefs({ @TypeDef(name = &quot;json&quot;, typeClass = JsonType.class) })
  public class UserRoles implements Serializable {
  
      private static final long serialVersionUID = 1L;
      @Id
      @Column(name = &quot;employeeId&quot;, length = 10)
      private String employeeId;
  
      @Column(name = &quot;username&quot;)
      private String username;
  
      @Type(type = &quot;json&quot;)
      @Column(name = &quot;roles&quot;, columnDefinition = &quot;json&quot;)
      private List&lt;String&gt; roles;
  
  }
  </code></pre>
  <p>I am trying to write the below query by using left join on username column. Query works fine as long as there are predicates(exp) for UsersStaging table . But if I add a predicate for userRoles table (roleExp) , the query fails .</p>
  <pre><code>JPAQuery&lt;UsersStaging&gt; query = new JPAQuery&lt;&gt;(entityManager);
          QUsersStaging usersStagingPath = QUsersStaging.usersStaging;
          QUserRoles userRolesPath = QUserRoles.userRoles;
          BooleanExpression exp = usersStagingPath.legalFirstName
                          .containsIgnoreCase(criteria.getValue());
          BooleanExpression roleExp = userRolesPath.roles.any().eq(&quot;SUPERADMIN&quot;);
          return query
                  .select(Projections.constructor(UsersStagingDTO.class, usersStagingPath.employeeId,
                          usersStagingPath.userName, usersStagingPath.email, usersStagingPath.isActive,
                          usersStagingPath.legalFirstName, usersStagingPath.legalLastName, usersStagingPath.legalFullName,
                          userRolesPath.roles))
                  .from(usersStagingPath).leftJoin(userRolesPath).on(usersStagingPath.userName.eq(userRolesPath.username))
                  .where(exp.and(roleExp)).limit(10).fetch();
      }
  </code></pre>
  <p>Getting the below exception</p>
  <pre><code>java.lang.NullPointerException: null
      at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:432) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:4007) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3793) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3671) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:746) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:602) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:5020) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4713) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2180) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2108) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
      at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:841) ~[hibernate-core-5.6.10.Final.jar:5.6.10.Final]
  </code></pre>