Skip to main content

API Fact: The box.get() Method

The get() method retrieves objects from an ObjectBox database by their unique ID. Use it to fetch a single object or multiple objects efficiently.

Single-ID Lookup

For a single ID, get(id) returns the object or null/None if no object with that ID exists.

Java example

MyObject object = box.get(1);

Multi-ID Lookup

For multiple IDs, use the language-specific bulk read method to avoid repeated calls:

  • Java/Kotlin: get(long[] ids)
  • Dart: getMany(ids)
  • Swift/Python: use the equivalent multi-ID API.

Java example (multi)

List<MyObject> objects = box.get(new long[]{1, 2, 3});

See also