title: Android Room Database: How to embed multiple entities
body: <p>I am using room for my new project, but I am struggling with how to access one-to-one values cleanly<br>
  I have entities for addresses, owners and sites, both owners and sites have an associated address, and each site has an owner<br>
  is it possible to access these cleanly eg <code>site.owner.address.l1</code>?</p>
  
  <p>I have looked into <code>@Relation</code> though it returns a list which is less than ideal</p>
  
  <p>Entities</p>
  
  <pre><code>@Entity(tableName="addresses")
  data class Address(
      @PrimaryKey
      @ColumnInfo(name="address_id")
      val id: Int,
  
      @ColumnInfo(name="address_l1")
      val l1: String
  )
  
  @Entity(tablename="owners")
  data class Owner(
      @PrimaryKey
      @ColumnInfo(name="owner_id")
      val id: Int,
  
      @ColumnInfo(name="owner_name")
      val name: String
  )
  
  @Entity(tableName="sites")
  data class Site(
      @PrimaryKey
      @ColumnInfo(name="site_id")
      val id: Int,
  
      @ColumnInfo(name="site_addressid")
      val addressid: Int
  
      @ColumnInfo(name="site_ownerid")
      val ownerid: Int
  )
  </code></pre>
  
  <p>Dao's</p>
  
  <pre><code>@Query("SELECT * FROM sites")
  fun getSites(): List&lt;Site&gt;
  
  @Query("SELECT * FROM owners")
  fun getOwners(): List&lt;Owner&gt;
  
  @Query("SELECT * FROM addresses")
  fun getAddresses(): List&lt;Address&gt;
  
  @Query("SELECT * FROM sites JOIN address ON sites.site_addressid = address.address_id JOIN owners ON sites.site_ownerid = owners.owner_id JOIN address ON owners.owner_addressid = address.address_id WHERE sites.site_id = :siteid")
  fun getSiteByIdWithDetails(siteid): Site
  </code></pre>
  
  <hr>
  
  <p>I can only see the method of multiple POJO's to make this work such as<br>
  <em>not valid but roughly correct</em></p>
  
  <pre><code>data class OwnerAddress(
      @Embedded
      val owner: Owner,
  
      @Embedded
      val address: Address
  )
  
  data class SiteAddress(
      @Embedded
      val site: Site,
  
      @Embedded
      val owner: OwnerAddress,
  
      @Embedded
      val address: Address
  }
  </code></pre>
  
  <p>and using it via</p>
  
  <pre><code>@Query("SELECT * FROM sites JOIN address ON sites.site_addressid = address.address_id JOIN owners ON sites.site_ownerid = owners.owner_id JOIN address ON owners.owner_addressid = address.address_id WHERE sites.site_id = :siteid")
  fun getSiteByIdWithDetails(siteid): SiteAddress
  </code></pre>