A question came in today about how to get ADFBC to allow querying for the literal asterisk character. By default, the OracleSQLBuilder implements the CriteriaAdapter interface (involved in translating view criteria into SQL where clause fragments) by replacing any asterisk character in the view criteria operand string with a percent sign so that the end-user can happily use either '*' or '%' as a search wildcard character.
However, if your data happens to have literal asterisks in them and you want to perform a query like '%*%' to find all the rows where a particular field contains that asterisk, then the default implementation is not going to do the job.
To solve the problem, the simplest approach is to:
- Create a custom OracleSQLBuilder subclass that overrides the correctOprandLiteral() method and which returns the argument passed in instead of calling super.
- Configure the application module to use this custom SQLBuilder class instead
The code for the custom SQLBuilder class looks like this:
package project1; import oracle.jbo.server.OracleSQLBuilderImpl; import oracle.jbo.server.SQLBuilder; public class CustomOracleSQLBuilder extends OracleSQLBuilderImpl { protected String correctOprandLiteral(String restVal) { /* super.correctOprandLiteral(restVal) */ return restVal; } public static SQLBuilder getInterface() { return new CustomOracleSQLBuilder(); } }
The property to set in the configuration is named jbo.SQLBuilder and you set its value to the fully-qualified name of the custom SQLBuilder class you want to use.
Problem solved!
12:35:50 PM
|