これらのテーブルは、データベース管理に OrmLite を使用している Android ベースのアプリケーションにあります。
私が持っている製品タイプFOLDERの数に応じて、x個の配列リストが必要です。
したがって、この場合、productId が parentId と等しい製品のリストが必要です。だから私はリストが欲しい
if(productType = FOLDER) {
if(productId = parentId){
//add product
}
}
基本的に私が最終的にやりたいことは、この場合、parentId がすべての製品で同じである製品のリストを含む 3 つのリストです。
私は多くのことを試しましたが、いくつかは他のものよりうまく機能しますが、実行したいコードは実際には nullpointer をスローします。
DatabaseHelper dbHelper = getHelper();
List<Product> productsParents = null;
try {
Dao<Product, Integer> dao = dbHelper.getDao();
PreparedQuery<Product> prepQu = dao.queryBuilder().where()
.eq("parentId", dao.queryBuilder().selectColumns("productId").where()
.eq("productType", ProductType.FOLDER).prepare()).prepare();
productsParents = dao.query(prepQu);
} catch (SQLException e) {
...
}
productParents が null を返すため、このコードは機能しません。わずかなヒントではありますが、意図したとおりに動作しません。誰かがコードでこれを行う方法を知っていれば、Java と ormlite の混合でも十分です。