title: How to build query with selecting by value of foreign object's field
body: <p>What is the best way for querying by using the value of foreign object's field?</p>
  
  <p>Suppose I have these three classes.</p>
  
  <p>UnitResult class which describes amount of Units:</p>
  
  <pre><code>@DatabaseTable
  public class UnitResult {
      public static final String ID_FIELD_NAME = "id";
      public static final String UNIT_COLUMN_NAME = "unit";
      public static final String RESULT_COLUMN_NAME = "result";
  
      @DatabaseField(generatedId = true, columnName = ID_FIELD_NAME)
      public Integer id;
  
      @DatabaseField(foreign = true, canBeNull = false, columnName = UNIT_COLUMN_NAME)
      public Unit unit;
  
      @DatabaseField(canBeNull = true, columnName = RESULT_COLUMN_NAME)
      public Integer result = null;
  }
  </code></pre>
  
  <p>Unit class which describes certain Units in a market (for example jiuce, snack etc.):</p>
  
  <pre><code>@DatabaseTable
  public class Unit {
      public static final String ID_FIELD_NAME = "id";
      public static final String TYPE_FIELD_NAME = "type";
  
      @DatabaseField(id = true, columnName = ID_FIELD_NAME)
      public int id;
  
      @DatabaseField(canBeNull = false, columnName = TYPE_FIELD_NAME)
      public UnitType type;
  }
  </code></pre>
  
  <p>And Enum of Unit type:</p>
  
  <pre><code>public enum UnitType {
      JUICES,
      DRINKS,
      SNACKS,
      NPD;
  }
  </code></pre>
  
  <p>So how can I query all <code>UnitResult</code> where <code>Unit</code> type is <code>UnitType.JUICES</code>?</p>