クエリを構築しているdaoの属性とは異なるエンティティの属性を参照するorderBy関数(生の文字列を持つものまたはパラメータ化されたものを使用)を使用できるように、ORMLiteでクエリを構築するにはどうすればよいですか? ? 私のクエリは次のように構築されています。
// Inner query for performances
QueryBuilder<Performance, String> 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<Order, String> ordersQB = orderDao.queryBuilder();
ordersQB.where().isNull("user_id").and().in("performance_id", performancesQB);
ordersQB.orderByRaw("performances.date DESC");
pastOrdersQuery = ordersQB.prepare();
そして、このクエリを実行しようとするたびに発生する例外は次のとおりです。
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` < ? ) )
ORDER BY performances.date DESC
ここで私が目にする唯一の解決策は、ネストされた選択の代わりに JOIN を使用して自分で生のクエリを作成することです。これは良い解決策でしょうか?