The <columnRenamingRule> Element

The <columnRenamingRule> element is used to tell Ibator to rename database columns before calculating the corresponding property name in an introspected table. This is useful when all columns in a table have a common prefix that should be removed before calculating the property name. For example, suppose a table contains the following columns:

It might be annoying to have the generated properties all containing the CUST prefix. The prefix can be removed by specifying a renamimg rule like this:

<columnRenamingRule searchString="^CUST_" replaceString="" />

Note that, internally, Ibator 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.

This element will be ignored for any column where a <columnOverride> element matches a column - the <columnOverride> will take precedence over the renaming rule.

If specified, the renaming rule in this element will rename the column before the property name is calculated. The calculated property name may be different depending on the value of the "useActualColumnNames" property on the corresponding <table> element. The following table shows the different values that will result if the column renaming rule shown above is applied to the field set shown above:

Column Name Property if useActualColumnNames="true" Property if useActualColumnNames="false"

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