Class VirtualPrimaryKeyPlugin

java.lang.Object
org.mybatis.generator.api.PluginAdapter
org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin
All Implemented Interfaces:
Plugin

public class VirtualPrimaryKeyPlugin extends PluginAdapter
This plugin can be used to specify columns that act as a primary key, even if they are not strictly defined as primary keys in the database.

To use the plugin, add a property to the table configuration specifying a comma delimited list of column names to use as a primary key:

<property name="virtualKeyColumns" value="ID1,ID2">

Author:
Jeff Butler
  • Constructor Details

    • VirtualPrimaryKeyPlugin

      public VirtualPrimaryKeyPlugin()
  • Method Details

    • validate

      public boolean validate(List<String> warnings)
      Description copied from interface: Plugin
      This method is called after all the setXXX methods are called, but before any other method is called. This allows the plugin to determine whether it can run or not. For example, if the plugin requires certain properties to be set, and the properties are not set, then the plugin is invalid and will not run.
      Parameters:
      warnings - add strings to this list to specify warnings. For example, if the plugin is invalid, you should specify why. Warnings are reported to users after the completion of the run.
      Returns:
      true if the plugin is in a valid state. Invalid plugins will not be called
    • initialized

      public void initialized(IntrospectedTable introspectedTable)
      Description copied from interface: Plugin
      This method is called just before the getGeneratedXXXFiles methods are called on the introspected table. Plugins can implement this method to override any of the default attributes, or change the results of database introspection, before any code generation activities occur. Attributes are listed as static Strings with the prefix ATTR_ in IntrospectedTable.

      A good example of overriding an attribute would be the case where a user wanted to change the name of one of the generated classes, change the target package, or change the name of the generated SQL map file.

      Warning: Anything that is listed as an attribute should not be changed by one of the other plugin methods. For example, if you want to change the name of a generated example class, you should not simply change the Type in the modelExampleClassGenerated() method. If you do, the change will not be reflected in other generated artifacts.

      Parameters:
      introspectedTable - the introspected table