MyBatis Generator (MBG) is a code generator for MyBatis MyBatis and iBATIS. It will generate code for all versions of MyBatis, and versions of iBATIS after version 2.2.0. 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.
MyBatis Generator will 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. JRE 6.0 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: