Home > front end >  Objectbox not saving list of objects
Objectbox not saving list of objects

Time:08-29

I'm attempting to save a custom object (called Data) that contains a list of (Datafield) objects. When i use the objectbox browser admin i am unable to see the column for the data at all and only see the UID listed under relations but not in the Data object definition of the json Here is the code i have for a Data object

@Entity
data class Data(
    @Id
    var id: Long = 0,
    var name: String = "",
    var lastEdited: String = "",
    var dataFields: List<DataField> = listOf(),
)

and here is the code i have for a Datafield object

@Entity
data class DataField(
    @Id
    var id: Long,
    @Unique(onConflict = ConflictStrategy.REPLACE)
    var fieldName: String = "",
    var dataFieldType: Int = DataFieldType.SHORTSTRING.ordinal,
    var dataValue: String = "",
    var first: String = "",
    var second: String = "",
    var third: String = "",
    var isEnabled: Boolean = true,
    var fieldHint: String? = "Enter value for $fieldName"
)

one Data object should contain a list of Data field objects. I've rebuilt my objectbox model and deleted the in app data/cache on the virtual device all to no avail.

CodePudding user response:

According to best of my experience.

there is no batch insert, you have to use loop, and extract each element and save it....

CodePudding user response:

In general, there are two options:

  • Related