objectbox / objectbox/objectbox-java
Detached entities 'ToMany.addAll' throws error
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Java
- Star
- 4.6k
- Fork
- 311
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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).
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại io.objectbox.relation.ToMany.addAll trong ToMany.java, sau đó so sánh đường đi của nó qua ensureBoxes, ensureEntities, ensureEntitiesWithTrackingLists và trackAdd với vòng lặp add đang hoạt động được mô tả trong báo cáo. Hoàn thành khi có thể truyền detached entities vào addAll mà không gặp DbDetachedException, với độ bao phủ cho trường hợp tái hiện đã báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java, kotlin
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 38/100