title: updating a field of a object in hibernate
body: <p>I have a <code>object A</code> which maps to <code>table A</code> in DB </p>
  
  <pre><code>class A {
       Integer id;
       String field2,field2;field3 ,... fieldN;
       //lots of other attribute
  }
  </code></pre>
  
  <p>Now i want to write a  DAO api that just updates a single field.One approach is that i can first load the object then changes the attribute i need and then use merge api</p>
  
  <pre><code>//start transcation
  A a = session.load(A.class, id);
  A.setfieldP(newValue)
  session.merge(A)
  //commit transcation
  </code></pre>
  
  <p>Now if i use following code</p>
  
  <pre><code> //start transcation
   A a = new A();
   a.setId(id); //set a id by which object A exists in DB
   A.setfieldP(newValue)
   session.merge(A)
   //commit transaction
  </code></pre>
  
  <p>Now second approach all fields except id and fieldP are set to null </p>
  
  <p>1)Now is there any other approach?<br>
  2)Can i use update instead of merge ?</p>