连续添加Type Converter实时数据触发器后
这是我的JobImages实体
@Entity
@TypeConverters({AddOnConverter.class})
public class JobImagesTable {
@PrimaryKey(autoGenerate = true)
int id;
@ColumnInfo(name = "job_marked_image")
String jobMarkedImage;
@ColumnInfo(name = "complexity_id")
int complexityId;
@ColumnInfo(name = "addons_data")
ArrayList<AddonService> addOnsData = new ArrayList<>();
@ColumnInfo(name = "status")
int status;
}
这是我的DAO
@Dao
public interface JobImagesDao {
@Query("SELECT * FROM JobImagesTable WHERE job_id=:job_id AND is_delete = 0")
LiveData<List<JobImagesTable>> getImagesForView(int job_id);
}
AddOnService Class
public class AddonService implements Parcelable {
@SerializedName("AddonID")
@Expose
private int addonID;
@SerializedName("Name")
@Expose
private String name;
@SerializedName("ExtraCredits")
@Expose
private double extraCredits;
@SerializedName("isSelected")
@Expose
private boolean isSelected;
public AddonService() {
}
}
转换器类
public class AddOnConverter {
@TypeConverter
public static ArrayList<AddonService> fromString(String value) {
Type listType = new TypeToken<ArrayList<AddonService>>() {}.getType();
return new Gson().fromJson(value, listType);
}
@TypeConverter
public static String fromArrayList(ArrayList<AddonService> list) {
Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}
}
此数据库类
@Database(entities = {JobImagesTable.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {
public abstract JobImagesDao getOriginImagesDao();
}
我没有得到任何编译时错误,但是在添加Type转换器后,屏幕上的Livedata连续触发了什么错误?