gpt4 book ai didi

android - 如何将arraylist存储在ormlite数据库中

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:15:32 24 4
gpt4 key购买 nike

我试图将类对象的数组列表保存到 ormlite 数据库中,但它给出了错误,java.lang.IllegalArgumentException:类 java.util.ArrayList 中没有字段具有 DatabaseField 注释

我的代码是

@DatabaseTable
public class ManageModelDetails {

@DatabaseField(generatedId = true)
private int id;

@DatabaseField(foreign = true, foreignAutoRefresh = true)
private ArrayList<ModelDetails> listModelDetails;

// ===============================================
public ManageModelDetails() {
super();
}

// ===============================================

public ManageModelDetails(int id, ArrayList<ModelDetails> listModelDetails) {
super();
this.id = id;
this.listModelDetails = listModelDetails;
}

// ===============================================

public void setId(int id) {
this.id = id;
}

public int getId() {
return id;
}

public void setModelList(ArrayList<ModelDetails> listModelDetails) {
this.listModelDetails = listModelDetails;
}

public ArrayList<ModelDetails> getModelList() {
return listModelDetails;
}

}

最佳答案

我认为您需要使用外国收藏。看这里:

关于android - 如何将arraylist存储在ormlite数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18441595/

24 4 0