MyBatis Generator (MBG) is a code generator for MyBatis MyBatis. It will generate code for all versions of MyBatis. It will introspect a database table (or many tables) and will generate artifacts that can be used to access the table(s). This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. MBG seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for join queries, or stored procedures.
MBG generates code in different styles, and for different languages, depending on how it is configured. For example, MBG can generate Java or Kotlin code. And MBG can generate MyBatis3 compatible XML - althought that is now considered a legacy use of MBG. The newer styles of generated code do not require XML.
Depending on how it is configured, MyBatis Generator may generate:
There is an inheritance relationship between these classes as appropriate. Note that the generator may be configured to generate different types of POJO hierarchies - for example, you may choose to generate a single domain object for each table if you so desire.
There are different variations of these statements depending on the structure of the table (for example, if the table doesn't have a primary key, then MBG will not generate an update by primary key function).
MyBatis generator is designed to run well in an iterative development environment, and can be included as an Ant task, or a Maven plugin, in a continuous build environment. Important things to note when running MBG iteratively include:
When running as an Eclipse feature the generator can also merge Java files and save user modifications to the generated Java files. The generator uses the Eclipse Java parser and AST walker to accomplish this. The Eclipse feature also has a few user interface enhancements that make the generator somewhat easier to run. Lastly, the Eclipse feature contributes a full user manual for the generator to the Eclipse help system.
The Eclipse feature can be found on the Eclipse marketplace here: https://marketplace.eclipse.org/content/mybatis-generator.
MBG has no dependencies beyond the JRE. Java 8 or above is required. Also, a JDBC driver that implements the DatabaseMetaData interface, especially the getColumns and getPrimaryKeys methods is required.
Support for MyBatis Generator is provided through the MyBatis user mailing list. You may subscribe to or view the mailing list through Google code here:
If you think you have found a bug, please ask a question about it on the user list first, before creating a new ticket. If you find a bug, or have a new feature request, you may open a new issue at GitHub here: