title: Room many to many relationships UNIQUE constraint failed when inserting into relational table
body: <p>I try to understand how to work with many to many relationships in room.</p>
  <p>I created a junction:</p>
  <pre><code>    @Entity(primaryKeys = {&quot;landing_id&quot;, &quot;takeoff_id&quot;})
      public class TakeoffLanding {
          public long takeoff_id;
          public long landing_id;
      }
  </code></pre>
  <p>I created a matching abstract method in the dao:</p>
  <pre><code>@Transaction
  @Insert
  abstract void insert(List&lt;TakeoffLanding&gt; takeoffLandings);
  </code></pre>
  <p>My takeoff and landing classes look like this:</p>
  <pre><code>@Entity(tableName = &quot;landing_table&quot;)
  public class Landing {
  
     @PrimaryKey(autoGenerate = true)
     public long landing_id;
  }
  </code></pre>
  <p>When trying to add to the database I get an error:</p>
  <blockquote>
  <p>android.database.sqlite.SQLiteConstraintException: UNIQUE constraint
  failed: TakeoffLanding.landing_id, TakeoffLanding.takeoff_id (code
  1555 SQLITE_CONSTRAINT_PRIMARYKEY)</p>
  </blockquote>
  <p>I probably don't fully understand the concepts behind this - but somehow I should be able to add more landings and more takeoffs with the same primary key? or do i need to have a primary key for each column (id-pair) in the junction as well?</p>