title: Order by attribute of foreign entity in ORMLite
body: <p>How can I build a query in ORMLite so that I can use the orderBy function (using either the one with the raw string or the parametrized one) referencing an attribute of a different entity than the one of the dao I'm building the query from? My query is built like that:</p>
  
  <pre><code>// Inner query for performances
  QueryBuilder&lt;Performance, String&gt; performancesQB = performanceDao.queryBuilder();
  performancesQB.selectColumns("performance_id");
  SelectArg performanceSelectArg = new SelectArg();
  performancesQB.where().lt("date", performanceSelectArg);
  
  // Outer query for Order objects, where the id matches in the performance_id
  // from the inner query
  QueryBuilder&lt;Order, String&gt; ordersQB = orderDao.queryBuilder();
  ordersQB.where().isNull("user_id").and().in("performance_id", performancesQB);
  ordersQB.orderByRaw("performances.date DESC");
  pastOrdersQuery = ordersQB.prepare();
  </code></pre>
  
  <p>And the exception I'm getting whenever I try to execute this query is:</p>
  
  <pre><code>android.database.sqlite.SQLiteException: no such column: performances.date:,
     while compiling: SELECT * FROM `orders` WHERE
       (`user_id` IS NULL AND `performance_id` IN
       (SELECT `performance_id` FROM `performances` WHERE `date` &lt; ? ) )
       ORDER BY performances.date DESC 
  </code></pre>
  
  <p>The only solution I see here is writing a raw query myself using a JOIN instead of a nested select. May this be a good solution?</p>