Available since 2000 THE standard for mobile databases SQL, rows, and columns • ORMs Bridge the gap between objects and tables • Object and NoSQL Databases Getting popular on mobile
Android • Started in 2011 • Open Source • First Android ORM with code generation For best performance Avoid reflection (super slow in Android) • “Lessons learnt” and inspiration for ObjectBox
sub-optimal APIs especially for objects • Column based databases Splitting up objects and putting them together • No innovations, no performance gains Look at the server side (NoSQL, et al.) • „So, if we designed a database today, how…“
learnings from greenDAO Objects first, replace everything else • A new database Not build on top of SQLite, NoSQL all through • Android first, cross platform Already runs on Linux, Windows, FreeBSD (macOS and iOS will follow) • It‘s pretty fast
update, updateOrInsert, insertOrReplace, … • There is just put • Semantics depend on the ID value of an object 0: new ID assigned, new object is put != 0: An existing object is replaced • It‘s OK to mix new and existing object for put
{ @Id long id; long customerId; @Relation Customer customer; } @Entity public class Customer { @Id long id; // References the ID property in the *Order* entity @Relation(idProperty = "customerId") List<Order> orders; }
gen. No byte code transformation, no surprises • Some code is generated into the entity Your code and gen. code co-exist in same file • @Generated marker with a content hash Changes are detected (& usually not required) • @Keep overrides @Generated Puts you in charge
a DB is a waste of time Testing logic including a DB is a great unit integration test • Android instrumentation tests: slow & hassle • Robolectric tests: slow • Testing with ObjectBox: Plain Java & JUnit No dexing / booting up just instant testing
& properties Needs to assign IDs internally etc. Stored in objectbox-models/default.json • Adding and removing just works • Renames: use “refID” from default.json Stable ID – apply before refactorings @Entity(refId = 1234) class AnyNameYouWant