Class CachePlugin

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

public class CachePlugin extends PluginAdapter
This plugin adds a cache element to generated sqlMaps. This plugin is for MyBatis3 targeted runtimes only. The plugin accepts the following properties (all are optional):
  • cache_eviction
  • cache_flushInterval
  • cache_size
  • cache_readOnly
  • cache_type

All properties correspond to properties of the MyBatis cache element and are passed "as is" to the corresponding properties of the generated cache element. All properties can be specified at the table level, or on the plugin element. The property on the table element will override any property on the plugin element.

Author:
Jason Bennett, Jeff Butler
  • Constructor Details

    • CachePlugin

      public CachePlugin()
  • 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
    • sqlMapDocumentGenerated

      public boolean sqlMapDocumentGenerated(Document document, IntrospectedTable introspectedTable)
      Description copied from interface: Plugin
      This method is called when the SqlMap document has been generated. This method can be used to add additional XML elements the the generated document.
      Parameters:
      document - the generated document (note that this is the MyBatis generator's internal Document class - not the w3c XML Document class)
      introspectedTable - The class containing information about the table as introspected from the database
      Returns:
      true if the document should be generated, false if the generated document should be ignored. In the case of multiple plugins, the first plugin returning false will disable the calling of further plugins. Also, if any plugin returns false, then the sqlMapGenerated method will not be called.