greenDAO 1.3 Release

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:

  1. Upgrade the greenDAO generator jar and completely regenerate code
  2. Upgrade the greenDAO jar in your Android project
  3. Fix the import statements; e.g. QueryBuilder and Query are now in de.greenrobot.dao.query
  4. 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
This entry was posted in News and tagged , , , , , , , . Bookmark the permalink.

3 Responses to greenDAO 1.3 Release

  1. Maragues says:

    The update went smooth and, for now, I’m not seeing session leaks or warnings anymore.

    Great job!

  2. Falko Richter says:

    Since you now support maven, do you plan to update your sample project with maven integration?

  3. DaoMaster says:

    My plan would be to update the sample with a real Gradle script, once the Android build system is ready for that. But a Mavenized sample might be a good idea, too…

Leave a Reply to DaoMaster Cancel reply