Tuesday, 15 December 2020

Can you rely on the order of Android Room Ids returned from a multi row insert

Im using Room for my local database within my current Android application.

I have a One-to-Many parent child table relationship where I would like to insert Multiple Parent rows, receive the auto generated ids back as a List then insert multiple children per parent Id.

Can I rely that Room returns the auto generated parent Ids in the same order as the parent rows I passed to the INSERT statement?

I receive 200 parent rows at a time, which means I do not want to have to insert individual parent rows as this approach will degrade performance.

Is there any method where I can insert multiple Parent -> Children one-2-many rows and have the children rows automatically receive the parent auto generated id?



from Can you rely on the order of Android Room Ids returned from a multi row insert

No comments:

Post a Comment