Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 5/3/2008; 11:34:40 AM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

April 2008
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Feb   May

Get Firefox!

Monday, April 28, 2008

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:

  1. Create a custom OracleSQLBuilder subclass that overrides the correctOprandLiteral() method and which returns the argument passed in instead of calling super.
  2. 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    



© Copyright 2008 Steve Muench.