Entity list relationships in Android Room
I think that TypeConverter
only works for static methods.
I say this based on the example from here and here
From the relationships section here:
"Because SQLite is a relational database, you can specify relationships between objects. Even though most ORM libraries allow entity objects to reference each other, Room explicitly forbids this."
So I guess it's best if you add @Ignore
on your locales
property and make a method on RoomLocaleDao
thats insert List<Locale>
and call it after insert Region.
The method that inserts a Region can return the inserted id.
If the @Insert method receives only 1 parameter, it can return a long, which is the new rowId for the inserted item. If the parameter is an array or a collection, it should return long[] or List instead. (https://developer.android.com/topic/libraries/architecture/room.html#daos-convenience)