title: Add new object into relationship in Realm
body: <p>I have a problem with Realm that ill my brain :(</p>
  
  <p>The problem is when I try to add a new object into RealmList. The object is inserted but it is not linked with the relationship.</p>
  
  <p>Now, my database has multiple relationships:</p>
  
  <p><strong>User</strong> 1-->M <strong>Trip</strong> 1-->M <strong>Vehicle</strong> 1-->M</p>
  
  <p>And then:</p>
  
  <p><strong>Vehicle</strong> 1-->M <strong>VehicleInfo</strong></p>
  
  <p><strong>VehicleInfo</strong> 1-->M <strong>Temperature</strong></p>
  
  <p>The problem reside when I try to insert a new object into Temperature class.</p>
  
  <p><strong>My classes:</strong></p>
  
  <p><strong>Vehicle:</strong></p>
  
  <pre><code>    @RealmClass
      public class Vehicle extends RealmObject
      {
          private String  state;                  //R: Reservado | P: Listo para embarcar | E: Embarcado | P1: Pdte. confirmar medidas | P2: Tª no válida | R1: No embarca
          private String  locata       = "";
          private String  customer     = "";
          private String  customerCode = "";
          private String  originPort   = "";      //Origin port
          private String  destinyPort  = "";      //Destiny port
          private int     fp;                     //Method pay (0 = CASH | 1 = CREDIT)
  
          //Relationship
          private Trip trip;                              //Inverse
          private RealmList&lt;VehicleInfo&gt;  vehicleInfo = new RealmList&lt;&gt;();    //One-to-many
          private RealmList&lt;Observation&gt; observations = new RealmList&lt;&gt;();;    //One-to-many
  .....
  }
  </code></pre>
  
  <p><strong>VehicleInfo:</strong></p>
  
  <pre><code>@RealmClass
  public class VehicleInfo extends RealmObject {
  
      private String  sv;                  //Vehicle type
      private String  licensePlate  = "";  //License
      private String  seal          = "";  //Seal
      private String  temperature   = "";  //Temperature control
      private String  iv            = "";  //Ida/Vuelta
      private String  commodityCode = "";
      private int     tara          = 0;   //TARA
      private int     packages      = 0;   //Bultos
      private int     weight        = 0;
      private double  length        = 0.0; //Meters
      private boolean flagFT;              //Flag Technical data
      private boolean flagDua;
      private boolean flagManifest;
      private boolean flagTransport;
      private boolean flagDangerCommodity;
  
      //Relationship
      private RealmList&lt;Temperature&gt; temperatures = new RealmList&lt;&gt;();   //One-to-many
  ....
  }
  </code></pre>
  
  <p><strong>My code to add new Temperature:</strong></p>
  
  <pre><code>Temperature temp = new Temperature();
  temp.setDate(appCommon.getCurrentTimeOrDate("DATE"));
  temp.setTime(appCommon.getCurrentTimeOrDate("TIME"));
  temp.setValue(Double.parseDouble(etTemp.getText().toString()));
  
  VehicleInfoPersistence.updateVehicleInfoTemperature(realm, vehicle.getLocata(), selectedUnitPosition, temp);
  updateRecycler(tempRecyclerAdapter, temp);
  </code></pre>
  
  <p><strong>Method to find and persist in Realm:</strong></p>
  
  <pre><code>public static VehicleInfo findVehicleInfoFromLocata(Realm realm, String locata, int position) {
          RealmQuery&lt;Vehicle&gt; query = realm.where(Vehicle.class).equalTo("locata", locata);
          Vehicle realmVehicle = query.findFirst();
  
          return realmVehicle.getVehicleInfo().get(position);
      }
  
  public static void updateVehicleInfoTemperature(Realm realm, String locata, int position, Temperature temperature) {
  
      Vehicle vehicle = VehiclePersistence.findVehicleFromLocata(realm, locata);
  
  realm.beginTransaction();
  Temperature realmTemp = realm.copyToRealm(temperature);
   vehicle.getVehicleInfo().get(position).getTemperatures().add(realmTemp);    
  realm.commitTransaction();
  </code></pre>
  
  <p>}</p>
  
  <p>How I said, object is created in database but it is not linked with the vehicle-->vehicleInfo-->Temperature.</p>
  
  <p>What's wrong in my code??</p>
  
  <p>Thanks in advance :)</p>