Everit Liquibase modules on maven-central
Recently, I decided to leave JPA and try something new concerning persistence. I evaluated many technologies and found Liquibase and QueryDSL to be the best for our needs. Both of them have their unique advantages.
Liquibase is perfect for maintaining database schemas. It is also possible to follow version changes when a deployment is performed and also to generate upgrade SQL scripts.
QueryDSL could work as a replacement of JPA Criteria API for us. JPA helped us to start a completely new way of programming. We could place our entities into separate modules and write utility functions that generate only a snippet from the complete SQL statement. However, we reached the limitations of JPA Criteria API soon. After I started to use QueryDSL, I felt that I superseded those limitations.
To use these technologies, we needed new tools and modules. We decided to use OSGi as the base of our framework, therefore, all our technologies must be modularized. By modularization, I do not only mean to extend the MANIFEST.MF file of the JAR files, but also to extend the functionality of our technologies to make it possible to use them within the concept of modularization. The following tools were implemented recently:
- liquibase-bundle: I extended the functionality of Liquibase to be able to import database schema snippets from different bundles. The snippets can be imported transitively. I also enhanced the standard OSGi support of Liquibase a little bit. With the change, extensions can be deployed as fragment bundles. I would like to contribute to the Liquibase project with the code so that I do not have to maintain the changes.
- liquibase-component: A simple OSGi Declarative Services component that uses the functionality of Liquibase-bundle to process changelog files. The component can be configured. One option is to upgrade the database, the other one is to dump the changes to SQL scripts so the db admin can perform the upgrade later. I am not sure if this component will have many future versions. It might happen that the code of the component will be integrated into the liquibase-datasource.
- liquibase-datasource: A configurable DataSource component. It needs a DataSource to access the database and also a database schema expression that points to the liquibase changelog file. After the database migration is finished, the component registers a new DataSource OSGi service.
- osgi-lqmg: Liquibase-QueryDSL-Metadata-Generator can be used to generate QueryDSL metadata classes directly from Liquibase changelog files. This tool uses the OSGi concept too, so instead of specifying the exact location of the changelog file, a Bundle-Capability must be defined.
- lqmg-maven-plugin: A maven plugin that uses osgi-lqmg to generate Liquibase Metadata classes. The plugin deploys the dependencies into an embedded OSGi container and uses them to find the Liquibase changelogs.
With the tools above, it is possible to use Liquibase and QueryDSL together easily within the OSGi world. I hope that this will become a common solution in the future.