简体   繁体   English

Android ORMLite将注释添加到库模型

[英]Android ORMLite add annotations to library model

I am using ORMLite in android. 我在android中使用ORMLite。 I have a library which provides me with a POJO which has certain fields (name, id, description) but it is not annotated with the ORMLite annotations. 我有一个为我提供POJO的库,该库具有某些字段(名称,ID,描述),但未使用ORMLite注释进行注释。

Is there a way to use ORMLite to store this model in my db without actually modifying the library model directly. 有没有一种方法可以使用ORMLite在我的数据库中存储此模型,而无需实际直接修改库模型。 Can i use a wrapper object somehow as an adapter? 我可以使用包装对象作为适配器吗?

public class Asset {
  private String id;
  private String name;
  private String description;
}

I have found the solution. 我找到了解决方案。 I can specify a config file which will describe each field and use that in the Database Helper. 我可以指定一个配置文件,该文件将描述每个字段并在数据库帮助器中使用它。

Here is the reference link. 这是参考链接。 Works perfectly! 完美的作品!

https://github.com/j256/ormlite-jdbc/blob/master/src/test/java/com/j256/ormlite/examples/fieldConfig/FieldConfigMain.java https://github.com/j256/ormlite-jdbc/blob/master/src/test/java/com/j256/ormlite/examples/fieldConfig/FieldConfigMain.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM