objectbox / objectbox/objectbox-java
Provide a way to force a refresh of the cached ToOne target
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 ToOne 关系 API,并阅读现有的 getTargetId() 和 target setter 行为。实现请求的 refresh 操作,使其从已知的 box 中获取相关实体,更新缓存并返回该实体;完成的标准是调用方可以刷新已更改的 target,而无需手动查找 box。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, java, kotlin
- 领域
- databases, mobile-dev
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100