title: select null fields in hibernate
body: <p>I had made select query in hibernate from employees table that had following columns:</p>
  
  <pre><code>private int id;
      private String firstname;
      private String lastname;
      private String email;
      private String phoneno;
      private Date hiredate;
      private Jobs jobid;
      private Integer salary;
      private Integer commpct;
      private Employee managerid;
      private Departments deptid;
  </code></pre>
  
  <p>On this table, 
  first record had managerid set to null, and afterwards every record managerid set to first record employeeid;</p>
  
  <p>when i select data from employees table using query: ("FROM EMPLOYEES") using following code:</p>
  
  <pre><code>Query query = session.createQuery("FROM Employee");
  
          List&lt;Employee&gt; employees = query.list();
  
          for(Employee employee:employees){
              System.out.println("ID=&gt;"+employee.getId()+"\tFirstName=&gt;"+employee.getFirstname()+"\tLastName=&gt;"+employee.getLastname()
                      +"\temail=&gt;"+employee.getEmail()+"\tPhoneNO=&gt;"+employee.getPhoneno()+"\tHireDate=&gt;"+employee.getHiredate()
                      +"\tJob=&gt;"+employee.getJobid().getJobtitle()+"\tMax Salary=&gt;"+employee.getJobid().getMaxsalary()
                      +"\tPresent Salary=&gt;"+employee.getSalary()+"\tCommission %=&gt;"+employee.getCommpct()+"\tManager=&gt;"+employee.getManagerid().getFirstname()+","+employee.getManagerid().getLastname()
                      +"\tDepartment ID=&gt;"+employee.getDeptid().getName());
  
          }
  </code></pre>
  
  <p>Exception throws bcoz first record managerid is null,</p>
  
  <p>Then, i used this query </p>
  
  <pre><code>Query query = session.createQuery("FROM Employee em WHERE em.managerid IS NOT NULL AND em.deptid IS NOT NULL");
  </code></pre>
  
  <p>I get the record other than first record.</p>
  
  <p><strong>ID is the primarykey and managerid is the foreign key pointing to Employees Table (id) field.
  All rows have id present but some rows/one row had managerid set to null.</strong></p>
  
  <p>My Question is how to get all the records even if first record managerid is set to null?</p>
  
  <p>What setting i had to made?</p>