objectbox-java
objectbox-java copied to clipboard
Modify ToMany without loading all relation entities
Currently, when you operate on a ToMany, an add or remove loads all entities.
Alternatively we should also have means to modify to-many relations without loading everything to avoid bloating memory (e.g. #392).
Ways to do it:
- Make ToMany lazy when it come to add and remove
- Provide methods to update relations outside of ToMany
- ?
Also think about only loading IDs instead of the whole entity. https://stackoverflow.com/q/54821446/9187282
This is a critical feature that's desperately needed.
In my sense, the current ToMany relations are pretty controversial. On the one hand it is convenient, makes the code more elegant, and for accessing a small number of records, it's quick enough. But on the other hand, It takes too much memory and is too slow for bulk processing (creating, accessing, clearing relations, and removing large number of records). The add method is very expensive. It's nearly prohibitive to call it progressively. One has to call addAll (if that's affordable) for create the relations once and for all.