Detached entities 'ToMany.addAll' throws error

未關閉
#412 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
java, kotlin
領域
database

研究方向

從 ToMany.java 中的 io.objectbox.relation.ToMany.addAll 開始,然後將它經過 ensureBoxes、ensureEntities、ensureEntitiesWithTrackingLists 和 trackAdd 的路徑,與報告中描述的可正常運作的 add 迴圈進行比較。當 detached entities 可以傳遞給 addAll 且不會拋出 DbDetachedException,並且已涵蓋報告中的重現案例時,即視為完成。

由索引模型根據 Issue 內容生成。

描述

bug

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).

主要語言
Java
星號
4.6k
分支
311
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

objectbox/objectbox-java 的其他 Issue

查看 objectbox/objectbox-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。