Class MyBatisGenerator

java.lang.Object
org.mybatis.generator.api.MyBatisGenerator

public class MyBatisGenerator extends Object
This class is the main interface to MyBatis generator. A typical execution of the tool involves these steps:
  1. Create a Configuration object. The Configuration can be the result of a parsing the XML configuration file, or it can be created solely in Java.
  2. Create a MyBatisGenerator object
  3. Call one of the generate() methods
Author:
Jeff Butler
See Also:
  • Method Details

    • generateOnly

      This is one of the main methods for generating code. This method is long-running, but progress can be provided and the method can be canceled through the ProgressCallback interface. This method will not write results to the disk. The generated objects can be retrieved from the getGeneratedJavaFiles(), getGeneratedKotlinFiles(), getGeneratedXmlFiles(), and getGeneratedGenericFiles() methods.
      Returns:
      any warnings created during the generation process
      Throws:
      SQLException - the SQL exception
      InterruptedException - if the method is canceled through the ProgressCallback
      InvalidConfigurationException - if the specified configuration is invalid
    • generateAndWrite

      This is one of the main methods for generating code. This method is long-running, but progress can be provided and the method can be canceled through the ProgressCallback interface. This method will write results to the disk.
      Returns:
      any warnings created during the generation process
      Throws:
      SQLException - the SQL exception
      IOException - Signals that an I/O exception has occurred.
      InterruptedException - if the method is canceled through the ProgressCallback
      InvalidConfigurationException - if the specified configuration is invalid
    • getGeneratedJavaFiles

      public List<GeneratedJavaFile> getGeneratedJavaFiles()
      Returns the list of generated Java files after a call to one of the generate methods. This is useful if you prefer to process the generated files yourself and do not want the generator to write them to disk.
      Returns:
      the list of generated Java files
    • getGeneratedKotlinFiles

      public List<GeneratedKotlinFile> getGeneratedKotlinFiles()
      Returns the list of generated Kotlin files after a call to one of the generate methods. This is useful if you prefer to process the generated files yourself and do not want the generator to write them to disk.
      Returns:
      the list of generated Kotlin files
    • getGeneratedXmlFiles

      public List<GeneratedXmlFile> getGeneratedXmlFiles()
      Returns the list of generated XML files after a call to one of the generate methods. This is useful if you prefer to process the generated files yourself and do not want the generator to write them to disk.
      Returns:
      the list of generated XML files
    • getGeneratedGenericFiles

      public List<GenericGeneratedFile> getGeneratedGenericFiles()
      Returns the list of generated generic files after a call to one of the generate methods. This is useful if you prefer to process the generated files yourself and do not want the generator to write them to disk.

      The list will be empty unless you have used a plugin that generates generic files or are using a custom runtime.

      Returns:
      the list of generated generic files