title: Room : LiveData from Dao will trigger Observer.onChanged on every Update, even if the LiveData value has no change
body: <p>I found that the LiveData returned by Dao will call its observer whenever the row is updated in DB, even if the LiveData value is obviously not changed.</p>
  
  <p>Consider a situation like the following example : </p>
  
  <p>Example entity</p>
  
  <pre><code>@Entity
  public class User {
      public long id;
      public String name;
      // example for other variables
      public Date lastActiveDateTime;
  }
  </code></pre>
  
  <p>Example Dao</p>
  
  <pre><code>@Dao
  public interface UserDao {
      // I am only interested in the user name
      @Query("SELECT name From User")
      LiveData&lt;List&lt;String&gt;&gt; getAllNamesOfUser();
  
      @Update(onConflict = OnConflictStrategy.REPLACE)
      void updateUser(User user);
  }
  </code></pre>
  
  <hr>
  
  <p>Somewhere in background thread</p>
  
  <pre><code>UserDao userDao = //.... getting the dao
  User user = // obtain from dao....
  user.lastActiveDateTime = new Date(); // no change to user.name
  userDao.updateUser(user);
  </code></pre>
  
  <p>Somewhere in UI</p>
  
  <pre><code>// omitted ViewModel for simplicity
  userDao.getAllNamesOfUser().observe(this, new Observer&lt;List&lt;String&gt;&gt; {
      @Override
      public void onChanged(@Nullable List&lt;String&gt; userNames) {
          // this will be called whenever the background thread called updateUser. 
          // If user.name is not changed, it will be called with userNames 
          // with the same value again and again when lastActiveDateTime changed.
      }
  });
  </code></pre>
  
  <p>In this example, the ui is only interested to user name so the query for LiveData only includes the name field. However the observer.onChanged will still be called on Dao Update even only other fields are updated.
  (In fact, if I do not make any change to User entity and call UserDao.updateUser, the observer.onChanged will still be called)</p>
  
  <p>Is this the designed behaviour of Dao LiveData in Room? Is there any chance I can work around this, so that the observer will only be called when the selected field is updated?</p>
  
  <hr>
  
  <p>Edit : I changed to use the following query to update the lastActiveDateTime value as KuLdip PaTel in comment suggest. The observer of LiveData of user name is still called.</p>
  
  <pre><code>@Query("UPDATE User set lastActiveDateTime = :lastActiveDateTime where id = :id")
  void updateLastActiveDateTime(Date lastActiveDateTime, int id);
  </code></pre>