agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.87k stars 598 forks source link

FlowManager.getModelAdapter(XXX.class).saveAll(models) not working with oneToMany #1696

Closed gongshoudao closed 3 years ago

gongshoudao commented 4 years ago

ISSUE_TEMPLATE

DBFlow Version: 4.2.4 Bug or Feature Request: Bug Description: FlowManager.getModelAdapter(XXX.class).saveAll(models) not working with oneToMany

eg.: 1.an ArrayList in XXX.class ; 2.

public class XXX extends BaseModel { private ArrayList giftList; @OneToMany(methods = {OneToMany.Method.DELETE, OneToMany.Method.SAVE}, variableName = "giftList") public ArrayList getDescList() { return giftList; }

}//end XXX.java

3. FlowManager.getModelAdapter(XXX.class).saveAll(models) XXX list save success , but XXX.giftList haven't.

agrosner commented 3 years ago

saveAll skips saving the many to many models for performance reasons. It is best to save each individual model in a transaction. Looks like all of *all methods do not respect one to many or model caching. Ill elevate to a bug since its not really expected.

agrosner commented 3 years ago

in meantime i would loop through each model:

models.forEach { model -> modelAdapter.save(model) } 
agrosner commented 3 years ago

in develop.