title: Ignore null values of entity bean while updating the table using Hibernate
body: <p><a href="https://forum.hibernate.org/viewtopic.php?f=1&amp;t=977537">Stuck on the same problem</a> Is there any method to ignore <code>null</code> values when updating the database in <code>Hibernate</code>?</p>
  
  <p>Whenever you call update(); of Session, it will also update the null values found in the object.</p>
  
  <p>Example: </p>
  
  <pre><code>User user = new User();
  user.setUserId(5);
  user.setUserName("Maarten");
  user.setUserFirstName(null); // but in database this value is not null
  
  session.update( user);
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>session.saveOrUpdate( user);
  </code></pre>
  
  <p>The DB will now update the user, but will set the user firstname to null (because it is null in the object).</p>
  
  <p>Is there any way or method in Hibernate to avoid this (I don't want to fire a select/ update query to set the bean)? that it will ignore the null value?</p>