title: how to filter a left join in jpa query
body: <p>I'm having trouble with a <code>JPA</code> object not being returned. I've got customers and addresses, customer can have zero or more addresses. I also soft delete items. This query works, except when there's no addresses returned I don't get the customer details back (returns <code>null</code>).</p>
  
  <p>So I set my query like this:</p>
  
  <pre><code>select c from Customer c
  left join fetch c.createUser 
  left join fetch c.lastUpdateUser 
  left join fetch c.addressBook a 
  where c.id = 1 and c.markForDelete = false 
  and (a.id is null or a.markForDelete = false)
  </code></pre>
  
  <p>It works fine if there's a row in <code>addressBook</code>. But if I delete all the addresses I'm getting no result back.</p>
  
  <p>The equivalent of what I'm trying to accomplish in SQL is:</p>
  
  <pre><code>select * from customers c
  left join customer_addresses ca
  on c.id = ca.customer_id
  and c.markForDelete = 0
  and ca.markForDelete = 0;
  </code></pre>
  
  <p>which works and gives me a single result.</p>