Embedded List<Obj?> room
I have models class
@Entity @TypeConverters({ConverterList.class, ConverterListObject.CardsOBJ.class, ConverterListObject.LoansOBJ.class, ConverterListObject.CountriesOBJ.class, ConverterListObject.Cards_creditOBJ.class, ConverterListObject.CreditsOBJ.class, ConverterListObject.Cards_installmentsOBJ.class, ConverterListObject.Cards_debitOBJ.class, }) public class DB { @PrimaryKey(autoGenerate = true) private long id; private List<String> news; private List<Cards> cards; @Embedded(prefix = "ru") private Ru ru; private List<String> documents; private List<Loans> loans; ...
Example Convert
public class ConverterListObject { public static class CardsOBJ { @TypeConverter public static List<Cards> stringToCards(String json) { Gson gson = new Gson(); Type type = new TypeToken<List<Cards>>() { }.getType(); List<Cards> measurements = gson.fromJson(json, type); return measurements; } @TypeConverter public static String CardsToString(List<Cards> list) { Gson gson = new Gson(); Type type = new TypeToken<List<Cards>>() { }.getType(); String json = gson.toJson(list, type); return json; } }
DB.class have constructor
public DB() { } public DB(long id, List<String> news, List<Cards> cards, Ru ru, List<String> documents, ...) { this.id = id; this.news = news; this.cards = cards; this.ru = ru; this.documents = documents; this.loans = loans; this.countries = countries; ...
but code not compiling, execute error Entities and POJOs must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type). – java.util.List