https://kotlinlang.org logo
r

runjorel

07/12/2019, 7:33 PM
I can’t seem to do a
batchInsert
for a
List<T>
because
batchInsert
will only accept a
List<Any>
. Anyone else with that issue?
t

tjohnn

07/13/2019, 9:03 AM
You could iterate through any collection within a transaction and insert each, all item would be batch-inserted together
👍 1
I never tried batchInsert though
t

tapac

07/17/2019, 8:20 PM
@runjorel, batchInsert accepts typed list, not List<Any>. How do you use it?
r

runjorel

07/17/2019, 8:27 PM
I’ve got a feeling it was because I was programming something inside a generic interface. something akin to this:
Copy code
interface CrudRepository<T, ID>{
   val table: IdTable<ID>
....
fun saveAll(entities: List<T>) ...
   table.batchInsert( entities ){ .. }  // where I was getting compiler error for List<Any>
I could only fix it via casts
t

tapac

07/18/2019, 1:51 PM
Try to use:
interface CrudRepository<T:Any, ID>{