You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to update all records in an entity based on new information. The purpose I use LazyList and do the get and remove is to avoid loading my entire query. Now remove doesn't work, how can I avoid loading the entire entity?
The main point I want to understand is how to work with items one by one on the lazylist without having to load all the list items into memory at the same time. I was hoping to load one by get(0), work with it, then unload it with remove(0), then load in the next one. Now I understand that LazyList is unmodifiable, so I can't remove(0), is there a way to unload the record I loaded before loading in the next record?
Activity
XilinJia commentedon Aug 28, 2020
I need to update all records in an entity based on new information. The purpose I use LazyList and do the get and remove is to avoid loading my entire query. Now remove doesn't work, how can I avoid loading the entire entity?
greenrobot-team commentedon Aug 31, 2020
LazyListis an unmodifiable list. See the class documentation. https://objectbox.io/docfiles/java/current/io/objectbox/query/LazyList.htmlEntities can be removed using their
Boxby passing their ID or their instance.https://docs.objectbox.io/getting-started#basic-box-operations
Edit: ok, maybe I misunderstood. Some other options:
Box.get(id)the entities andBox.put(entity),Box.getAll(), modify some of them, andBox.put(entities)them.Note: Please ask usage questions on Stack Overflow.
https://stackoverflow.com/questions/tagged/objectbox
XilinJia commentedon Aug 31, 2020
Thank you for responding.
The main point I want to understand is how to work with items one by one on the lazylist without having to load all the list items into memory at the same time. I was hoping to load one by get(0), work with it, then unload it with remove(0), then load in the next one. Now I understand that LazyList is unmodifiable, so I can't remove(0), is there a way to unload the record I loaded before loading in the next record?
greenrobot commentedon Aug 31, 2020
No need to unload; findLazy() - unlike findLazyCached() - should not hold on to previously fetched objects.
XilinJia commentedon Aug 31, 2020
When I do myLazyList.get(0), don't I get the record loaded?
greenrobot commentedon Aug 31, 2020
You do. And LazyList does not keep a reference.
greenrobot-team commentedon Sep 15, 2020
Updated JavaDoc in Query and LazyList will be available with the next update.