title: JPA join column with null values
body: <p>I have a query that works in plain SQL but is not working on JPA and can't figure out why. As you can guess from the title I have a clue but I don't know how to "fix" it.</p>
  
  <p>Here's the actual important code:</p>
  
  <pre><code>@Id 
  @Basic(optional = false) 
  @Column(name = "id", nullable = false) 
  private Integer id; 
  
  @Basic(optional = false) 
  @Column(name = "read_permission", nullable = false) 
  private boolean readPermission; 
  
  @Basic(optional = false) 
  @Column(name = "write_permission", nullable = false) 
  private boolean writePermission; 
  
  @Basic(optional = false) 
  @Column(name = "execute_permission", nullable = false) 
  private boolean executePermission; 
  
  @Basic(optional = false) 
  @Column(name = "admin_permission", nullable = false) 
  private boolean adminPermission; 
  
  @JoinColumn(name = "xinco_core_data_id", referencedColumnName = "id", nullable=true) 
  @ManyToOne(fetch = FetchType.LAZY) 
  private XincoCoreData xincoCoreDataId; 
  @JoinColumn(name = "xinco_core_group_id", referencedColumnName = "id", nullable=true) 
  @ManyToOne(fetch = FetchType.LAZY) 
  private XincoCoreGroup xincoCoreGroupId; 
  
  @JoinColumn(name = "xinco_core_node_id", referencedColumnName = "id", nullable=true) 
  @ManyToOne(fetch = FetchType.LAZY) 
  private XincoCoreNode xincoCoreNodeId; 
  
  @JoinColumn(name = "xinco_core_user_id", referencedColumnName = "id", nullable=true) 
  @ManyToOne(fetch = FetchType.LAZY) 
  private XincoCoreUser xincoCoreUserId; 
  </code></pre>
  
  <p>And here's the working sql:</p>
  
  <pre><code>select * from xinco_core_ace where xinco_core_user_id = 1 order by xinco_core_user_id, xinco_core_node_id, xinco_core_data_id; 
  </code></pre>
  
  <p>And here's what I'm attempting to do:</p>
  
  <pre><code>SELECT xca FROM XincoCoreAce xca WHERE xca.xincoCoreUserId.id = 1 ORDER BY xca.xincoCoreUserId.id, xca.xincoCoreGroupId.id, xca.xincoCoreNodeId.id, xca.xincoCoreDataId.id
  </code></pre>
  
  <p>The issue, I think, is that the xca.xincoCoreUserId.id, xca.xincoCoreGroupId.id, xca.xincoCoreNodeId.id, xca.xincoCoreDataId.id can be nulls.</p>
  
  <p>Any idea? Hopefully is easier to read :P</p>