the*_*osh 5 android android-sqlite greendao
我一直在尝试创建一个数据库,其中所有表都继承了某个元素,以便有可能拥有元数据.
因为我在模型生成器中添加了所有表声明这一行:
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
}
Run Code Online (Sandbox Code Playgroud)
问题是:
在我将这个生成到我的Android项目之后,我怎样才能确保这在现实生活中仍然存在?我现在需要改变什么吗?
官方文档没有关于继承的任何内容.
使用setSuperclass(String)支持非实体超类的继承.另一种方法是使用implementsInterface(String)实现接口.
我在有关继承和接口的新章节中更新了官方文档的一些细节:http: //greendao-orm.com/documentation/modelling-entities/
| 归档时间: |
|
| 查看次数: |
2710 次 |
| 最近记录: |