I’ve just posted a project on GitHub to simplify development with MyBatis. MyBatis is a Java persistence framework and a popular choice, even over Hibernate or JPA, when the developer wants more control over the SQL that is executed.
A good way to kickstart a MyBatis project it is to run MyBatis Generator. MyBatis Generator uses JDBC metadata to automatically generate the POJOs and the mappings for the tables in the database.
By default, the generated POJOs have getters and setters, which many consider useless boilerplate code. Here is where Lombok comes in handy: by using annotations and some clever compile-time code manipulation, getters and setters are no longer necessary and a thing of the past.
My plugin puts MyBatis and Lombok together. Without the plugin, for a simple table, MyBatis Generator could generate:
While using the plugin, it would generate:
Less code and improved legibility!
The project is hosted on GitHub: https://github.com/softwareloop/mybatis-generator-lombok-plugin
The project description explains how to configure the plugin and use it from Maven.