title: How to get record up to n level in Hibernate self join
body: <p>I have a class as:</p>
  
  <pre><code>    @Entity
      @Table(name="EMPL_MSTR_CUR_V1")
      public class EmployeeMasterVO {
          private String emplId;
          private String name; 
  
          private String supervisorId;
          private EmployeeMasterVO supervisor;
  
          /**
           * @return the emplId
           */
          @Id
          @Column(name="emplid") 
          public String getEmplId() {
              return emplId;
          }
          /**
           * @param emplId the emplId to set
           */
          public void setEmplId(String emplId) {
              this.emplId = emplId;
          }
          /**
           * @return the name
           */
          @Column(name="name")
          public String getName() {
              return name;
          }
  
          /**
           * 
           * @param supervisorId
           */
          public void setSupervisorId(String supervisorId) {
              this.supervisorId = supervisorId;
          }
  
  /**
       * 
       * @return String
       */
      @Column(name="SUPERVISOR_ID")
      public String getSupervisorId() {
          return supervisorId;
      }
  
          @ManyToOne(fetch = FetchType.LAZY)
          @JoinColumn( name = "SUPERVISOR_ID", insertable=false, updatable=false, nullable=true)
          @NotFound(action = NotFoundAction.IGNORE)
          public EmployeeMasterVO getSupervisor() {
              return supervisor;
          }
          public void setSupervisor(EmployeeMasterVO supervisor) {
              this.supervisor = supervisor;
          }
  
          //emplStatus - getter &amp; setter
         // employeeGroup -getter &amp; setter
      }
  </code></pre>
  
  <p>and having the criteria query as:</p>
  
  <pre><code> Criteria cri = getSPGSession().createCriteria(EmployeeMasterVO.class, "employeeMasterVO")
                      .createAlias("employeeMasterVO.supervisor", "supervisor",Criteria.LEFT_JOIN);
              cri.add(Restrictions.eq("employeeMasterVO.emplStatus", "3"));
              cri.add(Restrictions.ne("employeeMasterVO.employeeGroup", "C").ignoreCase());
  
  empldtls = cri.list();
  </code></pre>
  
  <p>Getting result as expected 
  but when I  do <code>empldtls.get(0).getSupervisor()</code> it again contain supervisor and so on.. </p>
  
  <p>So my question is how can I limit up to 2 level only means
  if I do  <code>empldtls.get(0).getSupervisor()</code> I should get supervisor dtails but
  when I do <code>empldtls.get(0).getSupervisor().getSupervisor()</code> I don't need this level. What shuld I do, any help is appriciated.</p>