Object/relation mapping (ORM)
greenDAO’s essence is offer an object oriented interface to data stored in the relational database SQLite. Just define for data model, and greenDAO will create Java data objects (entities) and DAOs (data access objects). This will save you a lot of boring code that just moves data back and forth. Beyond that, greenDAO offers some advanced ORM features like a session cache, eager loading, and active entities.
greenDAO does not make any compromises regarding performance. Databases are great for storing lots of data, and thus speed matters. Using greenDAO, most entities can be inserted, updated and loaded at rates of several thousand entities per second.
We are confident in greenDAO’s performance, and want to compare greenDAO to other ORM tools. We picked ORMLite first, because it seems to be a popular existing ORM tool for Android. For the same given entity, greenDAO inserts and updates entities over 2 times faster, and loads entities 4.5 times faster for loading entities than ORMLite. For typical applications the loading speed is the most important.
(Figures and chart updated 10-23-2011)
In addition to the high performance core of greenDAO, features like a session cache and intelligent eager loading techniques give an additional performance boost.
greenDAO’s core library is less than 100k in size, so adding greenDAO does not hurt your APK size.
If you want, entities can be made “active”: active entities resolve relations transparently (you just call a getter), and have update, delete, and refresh methods for convenient access to persistence functionality.
Protocol buffers support
greenDAO lets you persist objects directly into the database. If you talk via protobuf to your server, you do not need another mapping. All persistence operations of regular entities are available for protobuf objects. We believe this is a unique feature of greenDAO.
greenDAO will generate Java data objects (entities) and DAO objects. The DAO objects are tailored to the entities allowing the best possible mapping.
Future plan: generate adapters, and maybe CRUD activities.
greenDAO’s source code is completely available on . The source distribution also contains a JUnit test suite, which uses all features of greenDAO and is thus a great way to learn about greenDAO.