gpt4 book ai didi

android - List 作为@ForeignCollectionField ormlite

转载 作者:太空宇宙 更新时间:2023-11-03 12:08:22 25 4
gpt4 key购买 nike

我的模型类中有

List<String> _photo_array;

因为我可以在 String 类上添加注释,是否可以使用 ormLite 来持久化它?

最佳答案

since I can put anotation on String Class is it a way to persist it using ormLite?

您将必须创建一个包装 String 的实体。像这样的东西:

 @DatabaseTable
public class Photo {
@DatabaseField(generatedId = true)
private int id;
@DatabaseField
private String photo;
@DatabaseField(foreign = true)
private Model model;
}

然后您的模型类将有这些照片的 ForeignCollection

 @DatabaseTable
public class Model {
@DatabaseField(generatedId = true)
private int id;
@ForeignCollectionField()
private ForeignCollection<Photo> photos;
}

参见 foreign collection example .

关于android - List<String> 作为@ForeignCollectionField ormlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20349587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com