Object/relation mapping (ORM)
greenDAO’s essence is to 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.
Of all ORMs we know, greenDAO is the fastest. 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 invite you to compare greenDAO against other ORMs. We open sourced our benchmarks for full transparency. The graph below compares the 3 most popular ORM solutions for Android greenDAO, OrmLite, and ActiveAndroid (according to the popularity based on GitHub stars and Appbrain’s stats). greenDAO inserts and updates entities around 2 times faster, and loads entities around 4 times faster than ORMLite. For typical applications the loading speed is the most relevant one.
In addition to the high performance core of greenDAO, features like a session cache and intelligent eager loading techniques give an additional performance boost.
You can use greenDAO with the standard SQLite, which is embedded in Android, or you can use it with SQLCipher. Have a look at the database encryption documentation for details.
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 protocol buffer (protobuf) 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 GitHub. 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.
greenDAO is open source and is supported by its developers and its community.