objectbox / objectbox/objectbox-java
Detached entities 'ToMany.addAll' throws error
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
Issue Basics
- ObjectBox version 1.4.4
- Reproducibility: Always
Reproducing the bug
When creating entities (for inserting into ObjectBox), the ToMany field will throw this error if I use .addAll(list) it works if I use .add(entity) in a loop over the list.
Code
entity.bodyparts.addAll(bodyparts)
Logs & stackstraces
io.objectbox.exception.DbDetachedException: Cannot resolve relation for detached entities
at io.objectbox.relation.ToMany.ensureBoxes(ToMany.java:144)
at io.objectbox.relation.ToMany.ensureEntities(ToMany.java:184)
at io.objectbox.relation.ToMany.ensureEntitiesWithTrackingLists(ToMany.java:155)
at io.objectbox.relation.ToMany.trackAdd(ToMany.java:230)
at io.objectbox.relation.ToMany.addAll(ToMany.java:264)
Entities
lateinit var bodyparts: ToMany<BodypartEntity>
Misc
As mentioned above, the issue seems to be with .addAll specifically, whereas .add does work. The issue happens with detached entities, not using @Id(assignable = true).
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 ToMany.java 中的 io.objectbox.relation.ToMany.addAll 开始,然后将其经过 ensureBoxes、ensureEntities、ensureEntitiesWithTrackingLists 和 trackAdd 的路径,与报告中描述的可正常工作的 add 循环进行比较。当 detached entities 可以传递给 addAll 且不会抛出 DbDetachedException,并且已覆盖报告中的复现案例时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java, kotlin
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100