我想將類對象的arraylist保存到ormlite數據庫中,但它給出錯誤java.lang.IllegalArgumentException:沒有字段在類java.util中具有DatabaseField註釋.ArrayList如何在ormlite數據庫中存儲arraylist
我的代碼是
@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;
}
}
這是真的,如果列表的順序並不重要(的問題提到了一個ArrayList)。如果是這樣,那麼數組列表應該以自定義的方式存儲。 – Christine