Show Table of Contents
4.5. Adding Function Support
Refer to the section on user defined functions for adding new functions to Red Hat JBoss Data Virtualization. This example will show you how to declare support for the function and modify how the function is passed to the data source.
Following is a summary of all coding steps in supporting a new scalar function:
- Override the capabilities method to declare support for the function (REQUIRED)
- Implement a FunctionModifier to change how a function is translated and register it for use (OPTIONAL)
There is a capabilities method getSupportedFunctions() that declares all supported scalar functions.
An example of an extended capabilities class to add support for the "abs" absolute value function:
package my.connector;
import java.util.ArrayList;
import java.util.List;
public class ExtendedJDBCExecutionFactory extends JDBCExecutionFactory
{
@Override
public List getSupportedFunctions()
{
List supportedFunctions = new ArrayList();
supportedFunctions.addAll(super.getSupportedFunctions());
supportedFunctions.add("ABS");
return supportedFunctions;
}
}
In general, it is a good idea to call super.getSupportedFunctions() to ensure that you retain any function support provided by the translator you are extending.
This may be all that is needed to support a Red Hat JBoss Data Virtualization function if the JDBC data source supports the same syntax as Red Hat JBoss Data Virtualization. The built-in SQL translation will translate most functions as: "function(arg1, arg2, ...)".

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.