title: Handling Entities and Pojos
body: <p>Still new to Room and while most of the tutorials I've found are related to simple table and CRUD operations I am stuck on evolving this.</p>
  
  <p>Let's take this sample structures.</p>
  
  <p>Users entity</p>
  
  <pre><code>@Entity(tableName = "users")
  
  public class UsersEntity{
      @PrimaryKey(autoGenerate = true)
      private long id;
  
      @NonNull
      private String name;
  
      @NonNull
      private long roleId;
  }
  </code></pre>
  
  <p>Roles entity</p>
  
  <pre><code>  @Entity(tableName = "roles")
  
      public class RolesEntity{
          @PrimaryKey(autoGenerate = true)
          private long id;
  
          @NonNull
          private String name;
      }
  </code></pre>
  
  <p>First question: Should <code>Entity</code> objects be extended to also replace <code>POJO</code>? Or have Entities and POJO as separate classes?</p>
  
  <p>Extending from the Room setup, the way I would see User POJO is:</p>
  
  <pre><code>public class User{
     private long id;
     private Role role;
  }
  </code></pre>
  
  <p>Basically this setup should work both if the User would come as a json response from a web service or entered by the user in the app's input fields. </p>
  
  <p>However, this raises the second question: how to insert and retrieve user info?.
  Inserting seems possible as there could be something like </p>
  
  <p><code>userDAO.insertRole(userId)</code></p>
  
  <p>But how can I get the <code>Role</code> object of User by using Room and the userDAO? 
  I find inappropriate to do something like:</p>
  
  <pre><code>user = userDao.getUser(userId)
  user.setRole(roleDao.getRole(user.getRoleId)
  </code></pre>
  
  <p>Third question: it seems to be a good practice to have the table columns with _ (eg. <code>role_id</code>) but in java <code>roleId</code> is recommended as class property. If the result of a <code>@Query</code> for instance <code>select role_id from...</code> and the the POJO with <code>roleId</code> field, will fail so the query needs to be <code>select role_id as roleId...</code> to get it work. Is it a good practice to use camel case in table/column names in sqlite?</p>