1

我想在 DBFlow 中使用 OneToMany 关系,但出现以下错误:

错误:找不到符号变量 parentclass_parent_id

代码看起来(简化)如下:

class ParentClass
{
@Column
@PrimaryKey (autoincrement = true)
private long parent_id;

private ArrayList<ChildClass> childs;

@OneToMany(methods = {OneToMany.Method.ALL}, variableName = "childs")
public ArrayList<ChildClass> getMyChilds() {
    if (childs== null || childs.isEmpty()) {
        childs= (ArrayList<ChildClass>) SQLite.select()
                .from(Child.class)
                .where(Child_Table.parentclass_parent_id.eq(parent_id))
                .queryList();
    }
    return childs;
}
}

class ChildClass
{
@ForeignKey(references =

        {@ForeignKeyReference(columnName = "parentClassKey",

                foreignKeyColumnName = "parent_id")})

ParentClass parentClass;
}

知道有什么问题吗?

4

1 回答 1

0

添加@Column(name = "parentclass_parent_id")到您的主键值。

于 2017-04-19T12:36:13.940 回答