title: Reference properties of null referenced object in HQL
body: <p>Here I have two <code>Entity</code> class.</p>
  
  <pre><code>@Table(name = "AC_ACCOUNT_MASTER")
  public abstract class Account implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      @Column(name = "a_name")
      private String name;
  }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>@Table(name = "AC_VOUCHER_MASTER")
  public class Voucher implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private Double amt;
  
      @ManyToOne
      private Account drAc;
  
      @ManyToOne
      private Account crAc;
  
  }
  </code></pre>
  
  <p>There are 10 rows in <code>AC_VOUCHER_MASTER</code> table, where 4 <code>drAc</code> data are <code>null</code> in <code>AC_VOUCHER_MASTER</code> table. </p>
  
  <pre><code>session.createQuery("select v.id, v.amount, v.drAc.id,  v.crAc.id  from Voucher v").list();
  </code></pre>
  
  <p>The above query returns me 10 result (although 4 <code>drAc</code> are <code>null</code>). But when I put name refernce (<code>v.drAc.name</code>), it returns only those rows (6 rows) that <code>drAc</code> is not <code>null</code>.</p>
  
  <pre><code>"select v.id, v.amount, v.drAc.id, v.drAc.name, v.crAc.id , v.crAc.name  from Voucher v"
  </code></pre>
  
  <p>What Should I do now ? Is there to use <code>coalesce()</code> or something else ?</p>