0

重複の可能性: Android ORMLite で自己関係を作成するには?
上記の質問と同じ問題がありますが、答えが見つかりません。
私のテーブルは次のようになります。

  ---------------------
  CATEGORY
  ---------------------
  id            (Integer)
  name          (Text)
  parentId      (Integer)
  ---------------------

私が期待するもの:

 @DatabaseTable (tableName = "Category")
  public class Category{
      @DatabaseField (generatedId = true)
      private int id;

      @DatabaseField
      private String name;

      // how to map this one?
      private Category parent;
 }

親子関係をマッピングする方法を教えてください。私はCategoryこのように使いたい:

 Category parent = new Category();
 parent.name = "parent";

 Category child = new Category();
 child.setParent(parent);

別のこと:DaoでCategoryのすべての子を取得するにはどうすればよいですか? Sql クエリを使用する必要がありますか?
前もって感謝します。

4

1 に答える 1