As of now, we didn’t accept any code contribution (pull requests) from the community. This is going to change in the near future. As a first step, we have released the greenrobot Contributor Agreement today. If you plan to make contributions you need to print, fill out, and sign the agreement. We need you to send a scanned copy of the agreement to: opensource (at) greenrobot (dot) de.
In the upcoming weeks, we’ll start to have a look at pull requests from those of you who have signed the agreement. Please allow us some time, because we’re in the middle of two projects (apps using greenDAO, of course…).
Thank you for your patience. We want to make your contribution valuable for the growing greenDAO community. We think this can be an important step to increase the speed with which greenDAO evolves.
Lastly, we collected some hints for your successful contribution:
- Try to imitate the already existing code style and structure (we plan to have automatic Checkstyle checks in the future)
- Your code should be clean and concise (write simple code, especially for complex tasks)
- Use static analysis tools like FindBugs
- Every feature should be covered by unit tests
So again, thank you for commitment to open source. Let’s improve greenDAO together.
Multithreading and Maven/Gradle support are the two major themes of greenDAO 1.3. If you are using greenDAO from multiple threads, you are highly advised to upgrade to the latest version of greenDAO to prevent deadlocks. Fixing these issues led to small modification to Queries resulting in breaking changes that require small adjustments in your code. We seized this opportunity to refactor code and introduce a couple of new packages. There are a few actions required to upgrade on your side, see below for a list.
The second major change is using Gradle to build greenDAO, and more importantly, to push artifacts to Maven Central. This is now the primary location to get greenDAO (GitHub discontinued downloads anyway). So add dependencies to group ID “de.greenrobot” with the artifact IDs greendao and greendao-generator to add greenDAO to your project. If you don’t use Maven or Gradle, please download the jars directly from Maven Central.
Required actions to upgrade to greenDAO 1.3:
- Upgrade the greenDAO generator jar and completely regenerate code
- Upgrade the greenDAO jar in your Android project
- Fix the import statements; e.g. QueryBuilder and Query are now in de.greenrobot.dao.query
- Call forCurrentThread() before using a cached Query object and consider removing synchronized statements around the query. For details, please read the section “Executing queries in multiple threads” in the Queries documentation.
And finally, here is the greenDAO 1.3 change log:
- Reworked internal locking of insert/update/delete methods
- Fixed potential deadlocks when transactions are executed concurrently to one of the various insert/update/delete calls
- Reworked queries to be used without locking, query instances are now bound to their owner thread (breaking change!)
- Relations use the new lock-free query API
- Query classes were moved into the new query subpackage (breaking change!)
- Introduced Gradle build scripts for DaoCore and DaoGenerator projects
- Maven artifacts are pushed to Maven Central starting with this version
- Added two packages for classes used internally (identityscope and internal)
- Added new deleteByKeyInTx DAO method to efficiently delete multiple entities using their keys
- Added some checks to throw exceptions with nicer messages telling what’s wrong
- Added Travis CI
greenDAO V1.2.0 comes with new features and an important bug fix. We recommend everyone to upgrade.
New features and fixes in V1.2.0:
- Limited support of String PKs (no relations using String FKs yet)
- Fixed index creation (please update your schema)
- Added autoincrement() creating AUTOINCREMENT PKs
- Added CountQuery for creating SELECT COUNT (*) queries with QueryBuilder
- Added getDatabase in DaoMaster, DaoSession, and Dao
- Added insertOrReplaceInTx in Dao
- Added deleteInTx in Dao
- Made DAOs and DaoSessions in active entities transient (allows serialization of entities)
- Minor fixes
For the first time greenDAO supports entity without an long/Long PK. String PK are sometimes nice for key/value maps and caches. Starting with version 1.2.0 you can model those entities without an ID column, and directly load entities by its String PK saving you another query. There’s a limitation though in this version: entities with a String PK cannot be targeted of relations.
Action required to fix indexes: A bug in previous releases prevented database indexes from being generated. If you defined indexes before using greenDAO’s generator, it’s time to update your schema. One way you can do this is call the static createTable method of DAOs with indexes. The method’s second parameter is a flag indicating whether a “IF NOT EXISTS” semantic should be used. When updating your schema (SQLiteOpenHelper.onUpdate) you can call this method and pass true as this second parameters. This way only the missing indexes will be created because your tables already exist. If you do not have to migrate your data and you use DevOpenHelper, you can just increase your schema version. This way everything will be rebuild (dropped and created again) the next time you launch the app.
Posted in News Tagged index, indices, Release, String PK, V1.2
Since the 1.0 release of our Android ORM tool greenDAO, we saw activity growing. During the last four months we collected developer feedback and added our own experience with greenDAO. Version 1.1 does not come with big changes, but brings evolutionary new features and fixes:
- DeleteQuery for bulk deletes
- Entities may implement Java interfaces
- Entities may extend a Java class
- Added LIMIT and OFFSET support for QueryBuilder and Query
- Convenience methods to add named relationships
- SQL scripts are executed in a transaction by default
- Fixed queries with special column names (SQL keywords)
- Changed default names for to-many relations to end with “List”
- ORDER BY uses LOCALIZED collation for strings by default
Please have a look at the Download/Source page on how to get the new greenDAO 1.1 release.
Update note for greenDAO 1.0 users: Simply exchange the jar files for your generator and Android project. You have to make trivial changes to your code if you use to-many relations using the default name (e.g. you did not call setName on the ToMany object in the generator project). Because to-many relations are resolved to lists, greenDAO 1.1 changed the default property name by appending “List” to the target entities type. For example, if you have a to-many relationship to an entity of class User, the getter changed from getUser to getUserList.
Does your app already use greenDAO? Have a look .
With today’s advent of the , we did some performance measurements. We wanted to test how Android 4.0 influences the speed of SQL/ORM operations in comparison to the previous version 2.3 on the same hardware. The results were surprising:
The chart shows that while loading entities got around 40% faster, inserting and updating data runs at half speed only compared to the older version! We expected overall better results because of the more optimized Dalvik VM (despite SQLite is a native library, the Java API imposes an significant overhead). However, the update and insert results hint at major changes in SQLite itself or the file system. We’ll keep you updated, as soon we find out more.
Update: If you want to check the benchmarking code, you should clone the . The significant class for the benchmark is . Here you have to comment some lines in again to activate the performance tests. Those are: runTests(1000); (6x) and runBatchTests(list);. It’s an abstract class, so you have to run as an Android JUnit TestCase to start the benchmark. You will see the performance measurements in LogCat.
Today, we are happy to announce version 1.0 of greenDAO, which is also the first release. With this release, we think greenDAO is ready for a wide developer audience. The preview versions of greenDAO proved to be stable and some apps in the Android Market already use greenDAO. Android developers, stop messing around with SQL, start with greenDAO!
Of course, greenDAO 1.0 also brings new features:
To-many relations: Clearly, to-many relations were required for a 1.0 release. The are lazily loaded on the entities (just call a getter) and can be modeled with custom join properties.
Active entities: Entities can be “active”. Once loaded, you can update, refresh, and deleted active directly.
Significant performance improvements: Previous versions of greenDAO were already faster than its competitors by far. Nevertheless, we found ways to tweak performance even more, especially for loading entities.
Keep sections:Custom code can be embedded safely in entities which won’t be overwritten by code generator.
- More documentation (still far from perfect, let us know what is missing for you)
- Other minor improvements
If you have an non-trivial Android project relying on persistent data, you should give greenDAO a try! It will save you time. Focus on the interesting tasks and let greenDAO do the tedious persistence logic for you without compromising performance.
Get started with greenDAO.
PS.: The APK of greenDAO’s example project is a mere 47K. It contains the complete greenDAO core library. Slim, isn’t it?
greenDAO is designed for high performance. So let’s have a look at the latest performance results using a standard Nexus S for the upcoming 1.0 release:
Compared to the last preview release, loading entities was significantly improved. Especially loading for the first time entities with standard identity scope (the default configuration) got faster, actually twice as fast as before!
Remember, the identity scope also serves as a cache for entities. Using it, you can perform queries with a rate of 20,000 entities per second given that the entities are cached.
Side note: in contrast to queries, greenDAO’s load operations using the ID do not have to contact the database at all. Using load operations with cached entities result in rates of over 100,000 entity look ups per second.
Posted in News Tagged Identity Scope, Performance
Today we release a new release of greenDAO with two new major features: a builder for queries, and result lists that load data on the go. The new QueryBuilder class lets you build custom queries for your entities. Before we introduced QueryBuilder, you could do the same with formulating SQL. The QueryBuilder spares you the SQL part and has other advantages like compile time checks, and lazy loading of results. Lazy loading creates entities on the fly when you need it (on-demand).
Check out the new Queries page in the documentation section for details and how to use the new features.
Eight days after the public launch of greenDAO, we are releasing the next preview version of our ORM Mapper for Android. This version brings quite a few new features:
DaoSession: A concept similar to a Hibernate Session or the persistence context of JPA’s (Java Persistence API) EntityManager. The session cache is not just a plain data cache to improve performance, but also manages object identities. For example, if you load the same entity twice in a query, you will get a single Java object instead of two when using a session cache. This is particular useful for relations pointing to a common set of entities.
Active entities: A new type of entities that can resolve relations on the fly. Getters and setters for the referenced entities are generated. This is currently available for to-one relations; to-many and many-to-many will follow soon.
To-one eager loading: To-one relation entities can be loaded within the same SQL SELECT as the base entity. This improves performance alot when you navigate through entities using to-one relations. The interface keeps simple, greenDAO handles left outer joins for you in the background.
Transaction convenience: DaoSession provides two methods (runInTx and callInTx) to which you pass Runnable or Callable objects. The code inside of Runnable or Callable is executed in a database transaction.
Date type: A new property type for dates was added, which maps to java.util.Date and a long INTEGER on the database.
Entity refresh: Resets the values of an existing entity by loading the current database state.
SQL scripts: Surprisingly, Android does not offer executing of SQL scripts out of the box. Because this comes in handy for several tasks including data import and schema manipulation, we added this feature in greenDAO.
Despite we added some advanced ORM features, greenDAO keeps slim and fast. The APK of the example project is only 34 KByte including the full greenDAO runtime library with unit test base classes. We believe performance and size are crucial features for a mobile ORM framework.
The best way to get started with greenDAO is to download and play around with it. The download includes greenDAO jar files, javadocs, and an example project.
Let us know your thoughts on greenDAO.
Today, we release greenDAO to the public. greenDAO is an ORM tool for Android that maps Java objects to SQLite database tables. It does that pretty quick and offers a nice and clean object oriented API for Android developers. With greenDAO, you write less SQL (or no SQL at all) and work directly with objects. During greenDAO’s development, we did not compromise on performance. We believe it’s the fastest ORM tool for Android around. Have a look at greenDAO’s features for more details.
If your app relies on persistent data, give greenDAO a try! Download it and have a look at how to get started with the example project bundled with the download.
greenDAO is developed and maintained by greenrobot. At greenrobot, we already use greenDAO for our projects. We will open source it very soon. Stay tuned.
Posted in News Tagged Release