Я использовал в библиотеке ActiveRecord в своем проекте. когда моя модель состоит из нескольких полей, все они сохраняются должным образом. Но если моя модель содержит другие модели, я не могу сохранить ее. более подробно ниже:Я не могу справиться с ActiveRecord android
моей модели (так работает):
@Table(name="Weathers")
public class WeatherResponse extends Model {
@Expose
@Column(name="code")
@SerializedName("cod")
public int cod;
@Expose
@Column(name="base")
@SerializedName("base")
public String base;
public WeatherResponse() {
super();
}
}
, но если добавить поле:
@Expose
@Column(name = "sys")
@SerializedName("sys")
public Sys sys;
и сделать так:
@Table(name="Weathers")
public class WeatherResponse extends Model {
@Expose
@Column(name="code")
@SerializedName("cod")
public int cod;
@Expose
@Column(name="base")
@SerializedName("base")
public String base;
@Expose
@Column(name = "sys")
@SerializedName("sys")
public Sys sys;
public WeatherResponse() {
super();
}
}
это работает сохраняется. мой класс:
@Table(name = "Sys")
public class Sys extends Model {
@Expose
@Column(name = "message")
@SerializedName("message")
public String message;
@Expose
@Column(name = "country")
@SerializedName("country")
public String country;
@Expose
@Column(name = "sunrise")
@SerializedName("sunrise")
public String sunrise;
@Expose
@Column(name = "sunset")
@SerializedName("sunset")
public String sunset;
public Sys() {
super();
}
}
Я нашел пример, где модель содержит массив других моделей. отсюда я привел в качестве примера. enter link description here
но как сохранить в моем случае я не понимаю.
public void success(WeatherResponse weatherResponse, Response response) {
weatherResponse.save();
weatherResponse.sys.save();
}
Во-первых, сохранить объект SYS, то остальные – Yrgl