title: How update some fields of entity in Hibernate?
body: <p>I'm using Spring and Hibernate in a web application. I have an entity as follow:</p>
  
  <pre><code>@Entity
  public class MyClass{
     @Id
     @GeneratedValue
     protected Long id;
  
     protected String prop1;
  
     protected String prop2;
  
     /*
      *  Getters And Setters
      */
  
  }
  </code></pre>
  
  <p>When I want to update an instance of this entity, I get the instance from client by using jackson as follow:</p>
  
  <pre><code>@Inject
  SessionFactory sf;
  
  @RequestMapping("update")
  @Transactional
  public void update(@RequestBody MyClass myClass){
      sf.getCurrentSession.update(myClass);
  }
  </code></pre>
  
  <p>User data is as follow:</p>
  
  <pre><code>{
     "prop1": "my value1",
     "prop2": "my value2"
  }
  </code></pre>
  
  <p>this work correctly. My problem is when I want to update only <code>prop1</code>. In this state, I have to set <code>prop2</code> too. If I don't, it update <code>prop2</code> to <code>null</code>.   </p>
  
  <p><strong>How can only update <code>prop</code> without sending <code>prop2</code> from client to server</strong>?</p>