【问题标题】:DBFlow issue regarding oneToMany and ForeignKey关于 oneToMany 和 ForeignKey 的 DBFlow 问题
【发布时间】:2017-03-03 13:11:49
【问题描述】:

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

知道有什么问题吗?

【问题讨论】:

    标签: java android dbflow


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-18
      • 2023-03-11
      • 2014-07-10
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2010-11-15
      • 2016-10-22
      相关资源
      最近更新 更多