我想在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;
}


知道有什么问题吗?

最佳答案

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

08-17 20:50