title: Android Room Kotlin inner join
body: <p>I have two entities
  Accounts:</p>
  
  <pre><code>@Entity(tableName = "accounts",foreignKeys = arrayOf(
          ForeignKey(
                  entity = Currency::class,
                  parentColumns = arrayOf("id"),
                  childColumns = arrayOf("currencyId"),
                  onDelete = ForeignKey.CASCADE
          )
  ))
  data class Account (
          @PrimaryKey(autoGenerate = true)
          var id:Int=0,
          @ColumnInfo(name="name")
          var accountName:String,
          @ColumnInfo(name = "balance")
          var initialBalance:Double,
          var currencyId:Int,
          var date:Date,
          var isDefault:Boolean=true
  ){
      constructor():this(0,"",0.0,0,Date(),false)
  }
  </code></pre>
  
  <p>And Currencies:</p>
  
  <pre><code>@Entity(tableName = "currencies")
  data class Currency(
          @PrimaryKey(autoGenerate = true)
          var id:Int=0,
          @ColumnInfo(name="name")
          var currencyName:String,
          @ColumnInfo(name="code")
          var currencyCode:String
  )
  {
      constructor():this(0,"","")
  
      override fun toString(): String =currencyCode
  }
  </code></pre>
  
  <p>I want to embed a <code>currency</code> object in <code>account</code>. As you can see, I have one-to-many relationship between <code>currencies</code> and <code>accounts</code>. When I query the <code>accounts</code> entity I want to view its currency too.
  I tried adding an <code>@Embedded</code> field in <code>account</code> entity but it doesn't work <strong>obviously there is something I'm misunderstanding</strong> , the field is returned with null "No exception just null". And if possible to "flatten" the <code>currency</code> object inside the <code>account</code> object, this would be much better.<br/></p>
  
  <p>The point of all of this is, I want to display all accounts in <code>RecyclerView</code> with their currencies information. I'm now confused between <code>@Embedded</code> and <code>@Relation</code> any help would be much appreciated.<br/><br/>
  <strong>Edit</strong><br/>
  I don't know if this might help:<br/>
  This is my <code>AccountDao</code>:<br/></p>
  
  <pre><code>@Dao
  interface AccountDao {
      @Insert
      fun insertAll(items:Array&lt;Account&gt;)
  
      @Update
      fun update(item:Account)
  
      @Delete
      fun delete(item:Account)
  
      @Query("select * from accounts")
      fun getAll():LiveData&lt;Array&lt;Account&gt;&gt;
  }
  </code></pre>