Provide a way to force a refresh of the cached ToOne target
When the target entity of a ToOne relationship is changed after it's resolved and cached, there is no way to force the target to refresh from the database.
Describe the solution you'd like Provide a function that can be called that forces a new "get" from the box, caches the new entity, and returns it. This can be used when the app knows that the entity has been updated but wants those changes reflected in the related object.
Describe alternatives you've considered As a workaround/alternative, the app can find the correct box, get an updated entity using the getTargetId(), then set the ToOne target entity to the updated entity. This works but requires a lot of extra code for something it feels like objectbox should be able to handle (especially since the ToOne relationship already knows the correct box for the get operation).
Additional context Currently using this on Kotlin/Android.
Thanks! The recommended approach here is to get the source object again, e.g. run a query or get the object from its box again. Then access the ToOne again.
The underlying principle in ObjectBox is that objects do not change once you got them. Or for a ToOne at least the relation does not change as the target object itself is loaded on demand.
But may consider to add this feature as ToMany also has reset().
Understood. Thanks for taking a look. Adding a reset() function to ToOne that works like the ToMany is exactly what I am looking for :) It would definitely save me from the headaches from the workarounds.