Skip Headers

# Making a User-Defined Function Available to a Specific Platform

Previous

Next

To make the function that overrides a specific operation on your own platform, use the following procedure:

1. Create a subclass of the desired `DatabasePlatform` (from `oracle.toplink.platform.database` or `oracle.toplink.platform.database.oracle` package) that provides a public method that calls the protected superclass method `addOperator`:

       ...
       public class MyDatabasePlatform extends DatabasePlatform {
           protected void initializePlatformOperators() {
               super.initializePlatformOperators();
               // Create user-defined function
               ExpressionOperator toUpper = new ExpressionOperator();
               toUpper.setSelector(ExpressionOperator.ToUpperCase);
               Vector v = new Vector();
               v.addElement("UPPERCASE(");
               v.addElement(")");
               toUpper.printAs(v);
               toUpper.bePrefix();
               toUpper.setNodeClass(FunctionExpression.class);

               // Make it available to this platform only
               addOperator(toUpper);
           }
       }

2. Configure your session to use your platform subclass (see "Configuring Relational Database Platform at the Project Level" or "Configuring a Relational Database Platform at the Session Level").