title: How to insert `null` values to database using Hibernate?
body: <p>Please have a look at the below code.</p>
  
  <pre><code> String textName=request.getParameter("textName");
   String textadr1=request.getParameter("textadr1");
   String textadr2=request.getParameter("textadr2");
   String textcntry=request.getParameter("textcntry");
   String textregNo=request.getParameter("textregNo");
  
       AgentContact agentContact=new AgentContact();
       AgentContact agentContact2=new AgentContact();
       Agent agent=new Agent();
  
       agent.setName(textName);
       agent.setRegistrationNumber(textregNo);
       agent.setDateOfDealStart(textDateDealing);
       agent.setRegistrationDate(textregDate);
  
       session.save(agent);  
       session.save(agentContact);  
       session.save(agentContact2);          
       session.getTransaction().commit();
  </code></pre>
  
  <p>In the above code, we get the values from a form, that is why <code>request.getParameter()</code> is used. However, user may or may not fill some fields like name, so the <code>txtName</code> will be empty.</p>
  
  <p>However when this code is executed, I noticed Hibernate added "empty" string to these non specified Strings, instead of entering <code>null</code>. How can I set the code so it enters <code>null</code> values when the text are actually empty?</p>