title: How to save nested List<String> in RoomDB on Android
body: <p>Hey google have an example on using @Relation </p>
  
  <pre><code>@Entity
   public class Pet {
       int userId;
       String name;
       // other fields
   }
   public class UserNameAndAllPets {
     public int id;
     public String name;
     @Relation(parentColumn = "id", entityColumn = "userId")
     public List&lt;Pet&gt; pets;
   }
  </code></pre>
  
  <p>Is it possible to save list of String without creating extra class for it. I want to avoid incosistence between my JsonProperty and a room Entity</p>
  
  <p>W would like to have soemthing like that</p>
  
  <pre><code> public class UserNameAndAllPets {
     @JsonProperty("id")
     public int id;
     @JsonProperty("name")
     public String name;
     @Relation(parentColumn = "id")
     @JsonProperty("pets")
     public List&lt;String&gt; pets;
   }
  </code></pre>
  
  <p>Because I receive following Json:</p>
  
  <pre><code>{ 
   "id" : "1",
  "name" : "someName",
  "pets": ["cat", "dog", "camel"]
  }
  </code></pre>
  
  <p>Any one know the solution?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>now my example code looks like But I've got Error:
  <em>Error:Type of the parameter must be a class annotated with @Entity or a collection/array of it.</em></p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown=true)
  @Entity(tableName = TABLE_NAME)
  public class Item {
      @Ignore public static final String TABLE_NAME = "itemTable";
  
      @PrimaryKey(autoGenerate = true)
      Long id;
      @JsonProperty("supplierName")
      String supplierName;
      @JsonProperty("eventDescription")
      String eventDescription;
      @JsonProperty("eventDate")
      @TypeConverters(StringListToGsonConverter.class)
      Date date;
      @JsonProperty("carServiceType")
      @TypeConverters(StringListToGsonConverter.class)
      List&lt;String&gt; types;
  
      public ServiceHistoryItem(Long id, String supplierName, String eventDescription, Date date, List&lt;String&gt; types) {
          this.id = id;
          this.supplierName = supplierName;
          this.eventDescription = eventDescription;
          this.date = date;
          this.types = types;
      }
  
      public static class StringListToGsonConverter{
          @TypeConverter
          public static List&lt;String&gt; restoreList(String listOfString){
              return new Gson().fromJson(listOfString, new TypeToken&lt;List&lt;String&gt;&gt;() {}.getType());
          }
  
          @TypeConverter
          public static String saveListOfString(List&lt;String&gt; listOfString){
              return new Gson().toJson(listOfString);
          }
  
          @TypeConverter
          public static Date fromTimestamp(Long value) {
              return value == null ? null : new Date(value);
          }
  
          @TypeConverter
          public static Long dateToTimestamp(Date date) {
              return date == null ? null : date.getTime();
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT2</strong></p>
  
  <p>New Issue arise when saving items
  Dao cannot insert List of My Entities, no reason Why... though
  <em>Error:Type of the parameter must be a class annotated with @Entity or a collection/array of it.</em></p>
  
  <pre><code>@Dao
  interface ItemDao {
      @Query("SELECT * FROM " + Item.TABLE_NAME)
      fun getAll(): LiveData&lt;List&lt;Item&gt;&gt;
  
      @Query("DELETE FROM " + Item.TABLE_NAME)
      fun deleteAllServiceHistory()
  
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      fun insertNewItem(item: Item)
  
      @Insert(onConflict = OnConflictStrategy.REPLACE)
      fun insertNewItems(itemList: List&lt;Item&gt;) // &lt;--- Error
  
  }
  </code></pre>
  
  <p><strong>SOLUTION</strong> for Dao</p>
  
  <p>if you are using Kotlin you should use ArrayList</p>
  
  <pre><code>@Insert(onConflict = OnConflictStrategy.REPLACE)
          fun insertNewItems(itemList: ArrayList&lt;Item&gt;)
  </code></pre>