Objectbox ID initial value

43 views Asked by At

The initial value of id normally starts from 1 and progresses sequentially. I don't want it to start from 1, instead I want it to progress from a number I specify. Is this possible?

This should not be an external ID, but something that would deprive the relationships of the objectbox's features.

1

There are 1 answers

0
Uwe - ObjectBox On

It is not possible to change the start ID value. An alternative is to set IDs completely manually (but there are downsides to this). E.g.

@Id(assignable: true)
int id = 0;

Note that self-assigned IDs break automatic state detection (new vs. existing entity, e.g. typically a new entity has ID 0). Read more about that in the docs.

Source: https://docs.objectbox.io/advanced/object-ids#self-assigned-object-ids