The <ibatorPlugin> Element

The <ibatorPlugin> element is used to define a plugin. Plugins can be used to extend or modify the code generated by Ibator. This element is a child element of the <ibatorContext> element. Any number of plugins may be specified in a context. The plugins will be called in the order that are listed in the configuration.

For more information about plugins, see the Implementing Ibator Plugins reference page.

Ibator Supplied Plugins

Ibator supplies several plugins (all are in the package org.apache.ibatis.ibator.plugins). The supplied plugins demonstrate different types of tasks that can be accomplished with Ibator plugins. Source code for the plugins is available with the Ibator downloads, or can be viewed online here.

Plugin Description
(package).EqualsHashCodePlugin This plugin adds equals and hashCode methods to the Java model objects generated by Ibator.

The equals method generated by this class is correct in most cases, but will probably NOT be correct if you have specified a rootClass - because our equals method only checks the fields it knows about.

The hashCode method generated by this class is a very simplistic implementation. A better implementation would rely on the HashCodeUtil from - but we do not want to introduce another dependancy in this simple plugin.

(package).RenameExampleClassPlugin This plugin demonstrates usage of the initialized method by renaming the generated example classes generated by Ibator.

This plugin accepts two properties:

  • searchString (required) a regular expression used to search the default generated name of the example class.
  • replaceString (required) the string to be inserted on matches of the searchString.

For example, to rename the generated example classes from xxxExample to xxxCriteria, specify Example$ for searchString and Criteria for replaceString

(package).SerializablePlugin This plugin adds the marker interface to the Java model objects generated by Ibator. This plugin also adds the serialVersionUID field to the model classes.

Important: This is a simplistic implementation of and does not attempt to do any versioning of classes.

(package).SqlMapConfigPlugin This plugin generates a skeleton SqlMapConfig.xml file that contains references to the SqlMap.xml files generated by Ibator.

This plugin accepts three properties:

  • fileName (optional) the name of the generated file. this defaults to "SqlMapConfig.xml" if not specified.
  • targetPackage (required) the name of the package where the file should be placed. Specified like "com.mycompany.sql".
  • targetProject (required) the name of the project where the file should be placed.

Note: targetPackage and targetProject follow the same rules as the targetPackage and targetProject values on the sqlMapGenerator configuration element.

Required Attributes

Attribute Description
type The fully qualified name of the class that implements the plugin. The class must implement the interface org.apache.ibatis.ibator.api.IbatorPlugin, and must have a public default constructor. Note that it is far easier to extend the adapter class org.apache.ibatis.ibator.api.IbatorPluginAdapter than to implement the entire interface.

Optional Attributes


Child Elements