Skip to content

Detached entities 'ToMany.addAll' throws error #412

Open
@zoltish

Description

@zoltish

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions