我正在尝试将类对象的arraylist保存到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;
}

}

最佳答案

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

  • Foreign Collections
  • Another similar question
  • 关于android - 如何将数组列表存储在Ormlite数据库中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18441595/

    10-11 01:43