Java androiddbflow一对多完整示例
我对如何在DBFlow中声明外键感到困惑。在DBFlow()关系的入门页面中,它有Queen类的示例,但没有Ant或Colony类 是否有人拥有包含蚁后类的完整示例Java androiddbflow一对多完整示例,java,android,orm,dbflow,Java,Android,Orm,Dbflow,我对如何在DBFlow中声明外键感到困惑。在DBFlow()关系的入门页面中,它有Queen类的示例,但没有Ant或Colony类 是否有人拥有包含蚁后类的完整示例 谢谢这是您想要的示例代码: 父表: @Table(database = AppDatabase.class) public class CafeWebContentCategories extends BaseModel { @PrimaryKey private int id; @Column p
谢谢这是您想要的示例代码: 父表:
@Table(database = AppDatabase.class)
public class CafeWebContentCategories extends BaseModel {
@PrimaryKey
private int id;
@Column
private int categoryServerId;
@PrimaryKey
@Column
public int cafeServerId;
@Column
private String title;
@Column
private boolean isAuto;
public List<CafeWebChildContentCategories> subContentCategories;
@OneToMany(methods = {OneToMany.Method.ALL}, variableName = "subContentCategories")
public List<CafeWebChildContentCategories> getMyChannelSubContentCategories() {
if (subContentCategories == null || subContentCategories.isEmpty()) {
subContentCategories = SQLite.select()
.from(CafeWebChildContentCategories.class)
.where(CafeWebChildContentCategories_Table.parentId.eq(cafeServerId))
.queryList();
}
return subContentCategories;
}
public CafeWebContentCategories() {
}
// setters and getters
}
如果你对此有任何疑问,请问我。嗨,马赫迪,看起来不错,所以我接受了你的回答。不幸的是,您的示例来得有点晚。我决定改用realm。@Sam不使用
realm
,因为每个版本的新版本上的realm的大小都比旧版本大,我将所有的项目都从旧版本迁移到dbflow,dfblow比realmHi Mahdi有用,我试着使用dbflow,因为我读到它速度非常快。但是,很难获得对DBFlow的支持。文档也不是很好。但当DBFlow更成熟时,我肯定会研究它:)@samsqlite和包装器库,因为DBFlow比realm慢。我必须在我的大项目中切换到领域
@Table(database = AppDatabase.class)
public class CafeWebChildContentCategories extends BaseModel {
@PrimaryKey
@Column
public int id;
@Column
public int categoryId;
@Column
@ForeignKey(tableClass = CafeWebContentCategories.class,
references = @ForeignKeyReference(columnName = "parentId", foreignKeyColumnName = "cafeServerId"))
public int parentId;
@Column
private String title;
public CafeWebChildContentCategories() {
}
// setters and getters
}