The <domainObjectRenamingRule> Element

MyBatis Generator (MBG) uses the <domainObjectRenamingRule> element to rename database tables before calculating the corresponding domain object name. This is useful when all tables have a common prefix that should be removed before calculating the domain object name. For example, suppose some tables as the following:


It might be annoying to have the generated domain object name all containing the SYS prefix. The prefix can be removed by specifying a renaming rule like this:

<domainObjectRenamingRule searchString="^Sys" replaceString="" />

Note that, internally, MBG uses the java.util.regex.Matcher.replaceAll method for this function. See the documentation for that method and class for examples of the regular expression language used in Java.

If specified, the renaming rule in this element will rename all the names base on the domain object name. Suppose a table named SYS_USER :

Class Before using rename rule After using rename rule
Domain Object SysUser User
Key SysUserKey UserKey
Blob SysUserWithBLOBs UserWithBLOBs
Example SysUserExample UserExample
Mapper SysUserMapper UserMapper

This element is an optional child element of the <table> element.

Required Attributes

Attribute Description
searchString This is a regular expression that defines the substring to be replaced.

Optional Attributes

Attribute Description
replaceString This is a string to be substituted for every occurrence of the search string. If not specified, the empty string is used.

Child Elements