我想在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;
}
知道什么是错的吗?
答案 0 :(得分:0)
将@Column(name = "parentclass_parent_id")
添加到您的主键值。