title: Realm Android insertOrUpdate not updating
body: <p>The api response ( www.railwayapi.com/api/#trains-between-stations  ) doesn't contain any PrimaryKey field (the api is not under my control), so I created another class and set PK and the Response to it.
  I went through all similar question on StackOverflow and did accordingly. Still the data (fetched using Retrofit) is repeatedly getting inserted into Realm instead of updating. How do I solve this?</p>
  
  <p>This is how I save data into Realm: <strong>(EDITED)</strong></p>
  
  <pre><code> private void loadJSON(){
  
      SearchResultsApiInterface apiService = SearchResultsApiClient.getClient().create(SearchResultsApiInterface.class);
      Call&lt;SearchResultsResponse&gt; call = apiService.getTrainNameResponse(SSC,DSC,DATE,API_KEY);
      call.enqueue(new Callback&lt;SearchResultsResponse&gt;() {
          @Override
          public void onResponse(Call&lt;SearchResultsResponse&gt; call, Response&lt;SearchResultsResponse&gt; response) {
  
                             final SearchResultsResponse jsonResponse = response.body();
              jsonResponse.setKey(SSC+DSC+DATE);    //EDITED (SSC,DSC,DATE are the EditText valus enter by user)
              final List&lt;Train&gt; data =  jsonResponse.getTrain();
              String from = data.get(0).getFrom().getCode();
              String to = data.get(0).getTo().getCode();
              transaction = realm.executeTransactionAsync(new Realm.Transaction() {
                  @Override
                  public void execute(Realm realm) {
                      realm.insertOrUpdate(jsonResponse);
                  }
              }, new Realm.Transaction.OnSuccess() {
                  @Override
                  public void onSuccess() {
                      Toast.makeText(getApplicationContext(),"Data saved", Toast.LENGTH_LONG).show();}
              }, new Realm.Transaction.OnError() {
                  @Override
                  public void onError(Throwable error) {
                      Toast.makeText(getApplicationContext(),"Error in saving",Toast.LENGTH_LONG).show();}
              });
              SearchResultsDataAdapter adapter  = new SearchResultsDataAdapter(MainActivity.this,traindata);
              recyclerView.setAdapter(adapter);
              String toolbarTitle = from + " " + "-" + " " + to;
              toolbar.setTitle(toolbarTitle);
          }
  
          @Override
          public void onFailure(Call&lt;SearchResultsResponse&gt; call, Throwable t) {
              Log.d("Error", "" + t.getMessage());
          }
      });
  }
  </code></pre>
  
  <p>This is the Response: <strong>(EDITED)</strong></p>
  
  <pre><code>package com.android.vyshnav.indianrailwaysimpledesign.modelSearchTrain;
  
  import java.util.ArrayList;
  import java.util.List;
  import javax.annotation.Generated;
  import io.realm.RealmList;
  import io.realm.RealmObject;
  import io.realm.annotations.PrimaryKey;
  
  @Generated("org.jsonschema2pojo")
  public class SearchResultsResponse extends RealmObject{
  
  @PrimaryKey
  private String key;
  private int total;
  private String error;
  private RealmList&lt;Train&gt; train = new RealmList&lt;Train&gt;();
  private int response_code;
  
  public String getKey() {
      return key;
  }
  
  public void setKey(String key) {
      this.key = key;
  }
  
  /**
   *
   * @return
   * The train
   */
  public RealmList&lt;Train&gt; getTrain() {
      return train;
  }
  
  /**
   *
   * @param train
   * The train
   */
  public void setTrain(RealmList&lt;Train&gt; train) {
      this.train = train;
  }
  
  /**
   *
   * @return
   * The responseCode
   */
  public int getResponseCode() {
      return response_code;
  }
  
  /**
   *
   * @param responseCode
   * The response_code
   */
  public void setResponseCode(int responseCode) {
      this.response_code = responseCode;
  }
  
  /**
   *
   * @return
   * The total
   */
  public int getTotal() {
      return total;
  }
  
  /**
   *
   * @param total
   * The total
   */
  public void setTotal(int total) {
      this.total = total;
  }
  
  /**
   *
   * @return
   * The error
   */
  public String getError() {
      return error;
  }
  
  /**
   *
   * @param error
   * The error
   */
  public void setError(String error) {
      this.error = error;
  }
  
  
  }
  </code></pre>
  
  <p>This is the Json Response: </p>
  
  <pre><code>{
  "response_code": 200,
  "total": 1,
  "train": [
      {
          "no": 1,
          "name": "RAPTI SAGAR EXP",
          "number": "12511",
          "src_departure_time": "06:35",
          "dest_arrival_time": "03:50",
          "travel_time": "21:15",
          "from": {
              "name": "GORAKHPUR JN",
              "code": "GKP"
          },
          "to": {
              "name": "NAGPUR",
              "code": "NGP"
          },
          "classes": [
              {
                  "class-code": "FC",
                  "available": "N"
              },
              {
                  "class-code": "3E",
                  "available": "N"
              },
              {
                  "class-code": "CC",
                  "available": "N"
              },
              {
                  "class-code": "SL",
                  "available": "Y"
              },
              {
                  "class-code": "2S",
                  "available": "N"
              },
              {
                  "class-code": "2A",
                  "available": "Y"
              },
              {
                  "class-code": "3A",
                  "available": "Y"
              },
              {
                  "class-code": "1A",
                  "available": "N"
              }
          ],
          "days": [
              {
                  "day-code": "MON",
                  "runs": "N"
              },
              {
                  "day-code": "TUE",
                  "runs": "N"
              },
              {
                  "day-code": "WED",
                  "runs": "N"
              },
              {
                  "day-code": "THU",
                  "runs": "Y"
              },
              {
                  "day-code": "FRI",
                  "runs": "Y"
              },
              {
                  "day-code": "SAT",
                  "runs": "N"
              },
              {
                  "day-code": "SUN",
                  "runs": "Y"
              }
          ]
      }
  ]
  }
  </code></pre>