关于oneToMany和ForeignKey的DBFlow问题

时间:2017-03-03 13:11:49

标签: java android dbflow

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

知道什么是错的吗?

1 个答案:

答案 0 :(得分:0)

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