title: If Any field value of @EmbeddedId is null, which problem will arise?
body: <p>I am fetching a problem with Hibernate @EmbeddedId. Code of my @EmbeddedId is:</p>
  
  <pre><code>@Embeddable
  public class EnrolRegEmbededId implements Serializable
  {
   @Column(name="ENROL_NO")
  private String enrolNo;
  @Column(name="REG_NO")
  private String regNo;
  }
  </code></pre>
  
  <p>My entity class is :</p>
  
  <pre><code>@Entity
  @Table(name = "PTAX_ENROL_REG_PRINCIPAL_INFO")
  public class Enrol_reg_principal_info implements Serializable {
  
  @EmbeddedId
  private EnrolRegEmbededId enrolReg;
  @Column(name = "APPLN_TYPE")
  private String type;
  @Column(name = "FIRST_NM")
  private String f_name;
  @Column(name = "MIDDLE_NM")
  private String m_name;
  @Column(name = "LAST_NM")
  }
  </code></pre>
  
  <p>Problem is : I get data from 'Enrol_reg_principal_info' class when both enrolNo and regNo have value. But get NUllPointerException when either enrolNo or regNo have value.</p>
  
  <p>The hql is :
      <em>String hql = " from Enrol_reg_principal_info prin where prin.enrolReg.regNo=:id";</em>
   for get value for regNo.</p>
  
  <p><em>String hql = " from Enrol_reg_principal_info prin where prin.enrolReg.enrolNo=:ec";</em> 
  for get value for enrolNO.</p>
  
  <p>And the method is :</p>
  
  <pre><code>public EnrolRegPrinModel masterDetailsEC(String EC) throws Exception {
  EnrolRegPrinModel ecDetails = new EnrolRegPrinModel();
  Enrol_reg_principal_info info = new Enrol_reg_principal_info();
  
  Session s = null;
  try {
   s = sessionFactory.openSession();
  String hql = " from Enrol_reg_principal_info prin where 
  prin.enrolReg.enrolNo=:ec";
    Query q = s.createQuery(hql);
    q.setString("ec", EC);
  info = (Enrol_reg_principal_info) q.uniqueResult();
  } catch (Exception ex) {
   ex.printStackTrace();
  } finally {
   s.close();
  
   }
   return ecDetails;
  }
  </code></pre>
  
  <p>Please help. Thanks in advance</p>