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