Java API

ObjectBox is an an easy to use, object-oriented lightweight database and a full alternative to SQLite.

This is the ObjectBox documentation for our Java API. We strive to provide you with the easiest and fastest solution to store and retrieve data. Your feedback on ObjectBox and this documentation is very welcome. Use the "Was this page helpful?" smiley at the end of each page or send us your comments to contact[at] - thank you! :)

ObjectBox Changelog

V2.4.0 - 2019/10/15

Upgrade Notes

  • Android: the AAR libraries ship Java 8 bytecode. Your app will not build unless you upgrade to 3.2.1 or later.

  • Android: the ObjectBox LiveData and Paging integration migrated from Android Support Libraries to Jetpack (AndroidX) Libraries. If you are using them the library will not work unless you make the following changes in your app:

    • Upgrade to 3.2.1 or later.

    • Upgrade compileSdkVersion to 28 or later.

    • Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.

  • Note: this version requires backwards-incompatible changes to the generated MyObjectBox file. Make sure to rebuild your project before running your app so the MyObjectBox file is re-generated.

Improvements & Fixes

V2.4.0 - 2019/10/15

  • Class transformation works correctly if absolute path contains special characters. GH#135

V2.4.0-RC - Release Candidate 2019/10/03

  • Box: add getRelationEntities, getRelationBacklinkEntities,getRelationIds and getRelationBacklinkIds to directly access relations without going through ToMany.

  • Box: add putBatched to put entities using a separate transaction for each batch.

  • Box.removeByKeys() is now deprecated; use removeByIds() instead.

  • Query: fixed performance regressions introduced in version 2.3 on 32 bit devices in combination with ordered results

  • Fixed removing a relation and the related entity class. GH#490

  • Resolved issue to enable query conditions on the target ID property of a ToOne relation. GH#537

  • Box.getAll always returns a mutable list. GH#685

  • Do not overwrite existing objectbox-java or objectbox-kotlin dependency. GH#693

  • Resolved a corner case build time crash when parsing package elements. GH#698

  • When trying to find an appropriate get-method for a property, also check if the return type matches the property type. GH#720

  • Explicitly display an error if two entities with the same name are detected. GH#744

  • The code in MyObjectBox is split up by entity to make it less likely to run into the Java method size limit when using many @Entity classes. GH#750

  • Query: improved performance for ordered results with a limit. GH#769

  • Query: throw if a filter is used incorrectly with count or remove. GH#771

  • Documentation and internal improvements.

V2.3.4 - 2019/03/19

  • Avoid UnsatisfiedLinkError on Android devices that are not identifying as Android correctly

  • Fix displaying large objects in Object Browser 32 bit

  • Kotlin properties starting with "is" of any type are detected

  • Add objectbox-kotlin to dependencies if kotlin-android plugin is applied (previously only for kotlin plugin)

  • @BaseEntity classes can be generic

V2.3.3 - 2019/02/14

  • Fixed a bug introduced by V2.3.2 affecting older Android versions 4.3 and below

V2.3.2 - 2019/02/04

  • Potential work around for UnsatisfiedLinkError probably caused by installation errors mostly in alternative app markets

  • Support for Android Gradle Plugin 3.3.0: resolves deprecated API usage warnings.

V2.3.1 - 2019/01/08

Important bug fix - please update!

  • Fixed a corner case for Box.getAll() after removeAll() to return a stale object if no objects are stored

V2.3 - 2018/12/30

Improvements & Fixes

  • Query improvements: findIds and LazyList also consider the order; offset and limit for findIds

  • Improved 32 bit support: Windows 32 version officially deployed, fixed a corner case crash

  • Property queries for a boolean property now allow sum()

  • Added Box.isEmpty()

  • Supporting older Linux distributions (now starting at e.g. Ubuntu 16.04 instead of 18.04)

  • Fix for a corner case with Box.count() when using a maximum

  • Minor improvements to the ObjectBox code generator

  • Android: set extractNativeLibs to false to avoid issues with extracting the native library

V2.2 - 2018/09/27

Using @Unique for strings? Please update ASAP

  • Urgent fix: the unique check for string properties had false positives resulting in UniqueViolationException. This occurs only in combination with IndexType.HASH (the default) when hashes actually collide. We advise to update immediately to the newest version if you are using hashed indexes.

  • The release of new ObjectBox C API made us change name of the JNI library

    for better distinction. This should not affect you unless you depended on that (internal) name.

  • Improved compatibility with class transformers like Jacoco

  • Fixed query links for M:N backlinks

  • Improved error messages for the build tools

  • The Object Browser AAR now includes the required Android permissions

V2.1 - 2018/08/16

Minor Improvements & Fixes

  • Entity counts are now cached for better performance

  • Deprecated aggregate function were removed (deprecation in 1.4 with introduction of PropertyQuery)

  • Object browser hot fix: the hashed indexes introduced in 2.0 broke the object browser

  • Object browser fixes: filters with long ints, improved performance in the schema view

  • NPE fix in ToOne

  • Added a specific NonUniqueResultException if a query did not return an expected unique result

V2.0 - 2018/07/25

New Features/Improvements

  • Links and relation completeness and other features already announced in the 2.0 beta

  • Unique constraint for properties via @Unique annotation

  • Hash index: for strings the new default index is hash-based, which is more space efficient

  • Support for char type (16 bit)

  • RX lib deployed in JCenter

  • Rework of Query APIs: type safe properties (property now knows its owning entity)

  • Allow query conditions of links using properties (without parameter alias)

  • Query performance improvements when using order

  • Property based count: query for non-null or unique occurrences of entity properties (non-null and unique)

  • Additional query conditions for strings: "greater than", "less than", "in"

  • Added query conditions for byte arrays

  • Set query parameters for "in" condition (int[] and long[])

V2.0 beta – 2018/06/26

New Features/Improvements

  • Query across relation bounds using links (aka "join"): queries just got much more powerful. For example, query for orders that have a customer with an address on "Sesame Street". Or all persons, who have a grand parent called "Alice".

  • Backlinks for to-many relations: now ObjectBox is "relation complete" with a bi-directional many-to-many relation.

  • Query performance improvements: getting min/max values of indexed properties in constant time

  • Android: added Paging library support (architecture components)

  • Kotlin extensions: more Kotlin fun with ObjectBox KTX

  • Query parameters aliases: helps setting query parameters in complex scenarios (e.g. for properties of linked entities)

  • Improved query parameter verification

  • Many internal improvements to keep us going fast in the future

V1.5 and earlier

Check the release history for older releases