我一直在尝试创建一个数据库,其中所有表都继承某个元素,以便有可能拥有元数据。
我在模型生成器的所有表声明中添加了这一行:
public Entity addSuperEntity(Schema schema) {
Entity superEntity = schema.addEntity("superEntity");
superEntity.addIdProperty().primaryKey();
// SET RELATIONSHIP 1:m TO META DATA
}
public Entity addTable(Schema schema) {
Entity mEntity = schema.addEntity("MyEntity");
mEntity.setSuper("superEntity");
mEntity.addIdProperty().PrimaryKey();
// REST OF FIELDS
}
问题是:
现在,当我将其生成到我的 Android 项目后,我如何确保这在现实生活中仍然发生?我现在需要改变什么吗?
官方文档没有任何关于继承的内容。
使用 setSuperclass(String) 支持非实体超类的继承。另一种方法是使用 ImplementsInterface(String) 实现接口。
我在有关继承和接口的新部分中更新了官方文档,其中包含一些详细信息:http://greendao-orm.com/documentation/modelling-entities/ http://greendao-orm.com/documentation/modelling-entities/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)